summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Shell/Job.h28
-rw-r--r--Shell/Shell.cpp2
2 files changed, 14 insertions, 16 deletions
diff --git a/Shell/Job.h b/Shell/Job.h
index 3275ddb803..945a4a7afe 100644
--- a/Shell/Job.h
+++ b/Shell/Job.h
@@ -42,9 +42,7 @@
class Job : public RefCounted<Job> {
public:
- explicit Job()
- {
- }
+ static NonnullRefPtr<Job> create(pid_t pid, pid_t pgid, String command, u64 job_id) { return adopt(*new Job(pid, pgid, move(command), job_id)); }
~Job()
{
@@ -56,17 +54,7 @@ public:
#endif
}
- Job(pid_t pid, unsigned pgid, String cmd, u64 job_id)
- : m_pgid(pgid)
- , m_pid(pid)
- , m_job_id(job_id)
- , m_cmd(move(cmd))
- {
- set_running_in_background(false);
- m_command_timer.start();
- }
-
- unsigned pgid() const { return m_pgid; }
+ pid_t pgid() const { return m_pgid; }
pid_t pid() const { return m_pid; }
const String& cmd() const { return m_cmd; }
u64 job_id() const { return m_job_id; }
@@ -105,7 +93,17 @@ public:
void deactivate() const { m_active = false; }
private:
- unsigned m_pgid { 0 };
+ Job(pid_t pid, unsigned pgid, String cmd, u64 job_id)
+ : m_pgid(pgid)
+ , m_pid(pid)
+ , m_job_id(job_id)
+ , m_cmd(move(cmd))
+ {
+ set_running_in_background(false);
+ m_command_timer.start();
+ }
+
+ pid_t m_pgid { 0 };
pid_t m_pid { 0 };
u64 m_job_id { 0 };
String m_cmd;
diff --git a/Shell/Shell.cpp b/Shell/Shell.cpp
index b4e8ee0d40..ddfad4d600 100644
--- a/Shell/Shell.cpp
+++ b/Shell/Shell.cpp
@@ -572,7 +572,7 @@ RefPtr<Job> Shell::run_command(const AST::Command& command)
StringBuilder cmd;
cmd.join(" ", command.argv);
- auto job = adopt(*new Job(child, (unsigned)child, cmd.build(), find_last_job_id() + 1));
+ auto job = Job::create(child, (unsigned)child, cmd.build(), find_last_job_id() + 1);
jobs.set((u64)child, job);
job->on_exit = [](auto job) {