ref: 6d5e003446292f20c769c2a32674f9f2f4b41389 mrsh/include/shell/job.h -rw-r--r-- 904 bytes View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef SHELL_JOB_H
#define SHELL_JOB_H

#include <mrsh/array.h>
#include <stdbool.h>
#include <sys/types.h>
#include <termios.h>

struct mrsh_state;
struct process;

/**
 * A job is a set of processes, comprising a shell pipeline, and any processes
 * descended from it, that are all in the same process group.
 */
struct mrsh_job {
	pid_t pgid;
	struct termios term_modes;
	struct mrsh_state *state;
	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_terminated(struct mrsh_job *job);
bool job_stopped(struct mrsh_job *job);
void job_set_foreground(struct mrsh_job *job, bool foreground);

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

#endif