|
myshell 2.0.0
|
Job control related utilities. More...
Functions | |
| void | init_job_control () |
| Initialize job control. | |
| void | sigchld_handler (int) |
| SIGCHLD handler. | |
| int | wait_for_process (pid_t pid, int *status) |
| Wait for the process to finish. | |
| int | reap_children () |
| Wait for all background processes to finish. | |
| int | no_background_processes () |
| Return the number of currently running background processes. | |
| void | print_processes () |
| Print all internal processes. | |
| void | remove_completed_processes () |
| Remove all completed processes, i.e. whose status is DONE from the internal process table. | |
| void | print_completed_processes () |
| Print all completed background processes. | |
| void | update_jobs () |
| Update the internal process table. | |
| void | add_process (pid_t pid, int flags, const std::vector< std::string > &args) |
| Add a process to the internal process table. | |
| void | remove_process (pid_t pid) |
| Remove a process from the internal process table. | |
| void | set_process_status (pid_t pid, status_t status) |
| Change the status of a process in the internal process table. | |
Variables | |
| std::map< pid_t, process > | processes |
| The internal process table. | |
Job control related utilities.
Simplest job control implementation. Just for demonstration purposes. Features only process tracking and printing.
MAYBE: In future implement full job control supporting foreground and background processes with respecting process groups and signals handling process pipelines.
| void add_process | ( | pid_t | pid, |
| int | flags, | ||
| const std::vector< std::string > & | args ) |
Add a process to the internal process table.
| pid | The process ID. |
| flags | The process flags. |
| args | The process arguments. |
| void init_job_control | ( | ) |
| int no_background_processes | ( | ) |
Return the number of currently running background processes.
| void print_completed_processes | ( | ) |
Print all completed background processes.
| int reap_children | ( | ) |
Wait for all background processes to finish.
| void remove_process | ( | pid_t | pid | ) |
Remove a process from the internal process table.
| pid | The process ID. |
| void set_process_status | ( | pid_t | pid, |
| status_t | status ) |
Change the status of a process in the internal process table.
| pid | The process ID. |
| status | The new process status. |
| void sigchld_handler | ( | int | ) |
SIGCHLD handler.
Reaps the process and updates its internal status.
| signo | The signal number. |
| void update_jobs | ( | ) |
Update the internal process table.
Is exactly equivalent to calling print_completed_processes() and remove_completed_processes() sequentially.
| int wait_for_process | ( | pid_t | pid, |
| int * | status ) |
Wait for the process to finish.
| pid | The process ID. |
| status | The process status. |
WIFEXITED and WIFSIGNALED are false for the process, the return value is undefined.| std::map<pid_t, process> processes |
The internal process table.
Maps process IDs to process objects.