diff options
Diffstat (limited to 'src/jobs.c')
| -rw-r--r-- | src/jobs.c | 42 |
1 files changed, 21 insertions, 21 deletions
@@ -49,7 +49,7 @@ typedef struct job { pid_t pgid; /**< Its process group, or 0 if it has none of its own. */ proc *procs; int nprocs; - char *text; /**< Command text for listings; may be NULL. */ + char *text; /**< Command text for listings; may be nullptr. */ bool announce; /**< Changed state; tell the user before the next prompt. */ } job; @@ -62,7 +62,7 @@ job *job_list; /** * @brief The job that processes created right now belong to. * - * Set between job_begin() and the end of launching. NULL otherwise, + * Set between job_begin() and the end of launching. nullptr otherwise, * including whenever job control is off. */ job *job_launching; @@ -134,7 +134,7 @@ int wait_fg(pid_t pid) { /** * @brief Create an empty job and put it at the head of the table. - * @param text Command text (ownership passes to the job), or NULL. + * @param text Command text (ownership passes to the job), or nullptr. * @return The new job. */ static job *job_new(char *text) { @@ -161,7 +161,7 @@ static void job_free(job *j) { } } if (job_launching == j) - job_launching = NULL; + job_launching = nullptr; free(j->procs); free(j->text); free(j); @@ -365,7 +365,7 @@ void jobs_notify(void) { * POSIX asks. * * @param pid The child. - * @param n The command, for the listing text. May be NULL. + * @param n The command, for the listing text. May be nullptr. */ void jobs_add(pid_t pid, const node *n) { job *j = job_new(node_text(n)); @@ -384,7 +384,7 @@ void jobs_add(pid_t pid, const node *n) { void jobs_forget(void) { while (job_list) job_free(job_list); - job_launching = NULL; + job_launching = nullptr; jc_on = false; opt.monitor = false; } @@ -543,7 +543,7 @@ void job_child_setup(void) { * number if the job stopped or was killed. */ int job_wait_fg(job *j) { - job_launching = NULL; + job_launching = nullptr; if (!j->nprocs) return 0; if (jc_on && j->pgid) { @@ -553,7 +553,7 @@ int job_wait_fg(job *j) { kill(-j->pgid, SIGCONT); } for (;;) { - proc *p = NULL; + proc *p = nullptr; for (int i = 0; i < j->nprocs && !p; i++) { if (!j->procs[i].done && !j->procs[i].stopped) p = &j->procs[i]; @@ -631,7 +631,7 @@ int job_status_of(const job *j, pid_t pid) { */ void job_release(job *j) { if (job_launching == j) - job_launching = NULL; + job_launching = nullptr; if (!j->nprocs || job_get_state(j) == JOB_DONE) job_free(j); } @@ -644,7 +644,7 @@ void job_release(job *j) { * @param j The job. */ void job_end_bg(job *j) { - job_launching = NULL; + job_launching = nullptr; if (!j->nprocs) { job_free(j); return; @@ -663,19 +663,19 @@ void job_end_bg(job *j) { * * `%N` is job number N. `%%`, `%+` and `%` the current job. `%-` the * previous job. `%text` a job whose command starts with `text`. `%?text` - * a job whose command contains `text`. NULL selects the current job. + * a job whose command contains `text`. nullptr selects the current job. * - * @param spec The specification, or NULL. - * @return The job, or NULL if there is no such job. + * @param spec The specification, or nullptr. + * @return The job, or nullptr if there is no such job. */ static job *job_find(const char *spec) { if (!spec || !strcmp(spec, "%") || !strcmp(spec, "%%") || !strcmp(spec, "%+")) return job_list; if (!strcmp(spec, "%-")) - return job_list ? job_list->next : NULL; + return job_list ? job_list->next : nullptr; if (spec[0] != '%') - return NULL; + return nullptr; spec++; long id; if (parse_long(spec, &id)) { @@ -683,7 +683,7 @@ static job *job_find(const char *spec) { if (j->id == id) return j; } - return NULL; + return nullptr; } bool anywhere = spec[0] == '?'; if (anywhere) @@ -692,11 +692,11 @@ static job *job_find(const char *spec) { for (job *j = job_list; j; j = j->next) { if (!j->text) continue; - if (anywhere ? strstr(j->text, spec) != NULL + if (anywhere ? strstr(j->text, spec) != nullptr : !strncmp(j->text, spec, len)) return j; } - return NULL; + return nullptr; } /** @@ -781,7 +781,7 @@ int builtin_wait(int argc, char **argv) { } int status = 0; for (int i = 1; i < argc; i++) { - job *j = NULL; + job *j = nullptr; if (argv[i][0] == '%') { j = job_find(argv[i]); } else { @@ -902,7 +902,7 @@ int builtin_fg(int argc, char **argv) { sh_warn("fg: no job control"); return 2; } - job *j = job_find(argc > 1 ? argv[1] : NULL); + job *j = job_find(argc > 1 ? argv[1] : nullptr); if (!j || job_get_state(j) == JOB_DONE) { sh_warn("fg: %s: no such job", argc > 1 ? argv[1] : "current"); return 1; @@ -934,7 +934,7 @@ int builtin_bg(int argc, char **argv) { int status = 0; int i = 1; do { - job *j = job_find(i < argc ? argv[i] : NULL); + job *j = job_find(i < argc ? argv[i] : nullptr); if (!j || job_get_state(j) == JOB_DONE) { sh_warn("bg: %s: no such job", i < argc ? argv[i] : "current"); status = 1; |
