~emersion/mrsh

2ee0faf76fe681c14ab18690a2d852a4065babac — Simon Ser 1 year, 1 month ago 1e831a5
job_finished → job_terminated
3 files changed, 3 insertions(+), 4 deletions(-)

M include/shell/job.h
M shell/job.c
M shell/task/task.c
M include/shell/job.h => include/shell/job.h +1 -2
@@ 15,14 15,13 @@ struct process;
struct mrsh_job {
	pid_t pgid;
	struct mrsh_state *state;
	bool finished;
	struct mrsh_array processes; // struct process *
};

struct mrsh_job *job_create(struct mrsh_state *state, pid_t pgid);
void job_destroy(struct mrsh_job *job);
void job_add_process(struct mrsh_job *job, struct process *proc);
bool job_finished(struct mrsh_job *job);
bool job_terminated(struct mrsh_job *job);

bool init_job_child_process(struct mrsh_state *state);
void update_job(struct mrsh_state *state, pid_t pid, int stat);

M shell/job.c => shell/job.c +1 -1
@@ 113,7 113,7 @@ void job_add_process(struct mrsh_job *job, struct process *proc) {
	mrsh_array_add(&job->processes, proc);
}

bool job_finished(struct mrsh_job *job) {
bool job_terminated(struct mrsh_job *job) {
	for (size_t j = 0; j < job->processes.len; ++j) {
		struct process *proc = job->processes.data[j];
		if (!proc->terminated) {

M shell/task/task.c => shell/task/task.c +1 -1
@@ 36,7 36,7 @@ int task_poll(struct task *task, struct context *ctx) {
static void destroy_finished_jobs(struct mrsh_state *state) {
	for (ssize_t i = 0; i < (ssize_t)state->jobs.len; ++i) {
		struct mrsh_job *job = state->jobs.data[i];
		if (job_finished(job)) {
		if (job_terminated(job)) {
			job_destroy(job);
			--i;
		}