Lines Matching +full:can +full:- +full:secondary
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
32 * |-- runconsoles [ttyX]
33 * | `-- utility primary
34 * |-- runconsoles [ttyY]
35 * | `-- utility secondary
37 * `-- runconsoles [ttyZ]
38 * `-- utility secondary
41 * so we can ensure the session leader stays around until the actual program
81 /* -1: not started, 0: reaped */
98 static const char secondary[] = "secondary"; variable
115 if (consinfo->pid != -1 && consinfo->pid != 0) in kill_consoles()
116 kill(consinfo->pid, sig); in kill_consoles()
141 * unblock so we can SIGKILL. Similarly, SIGCHLD may be blocked, but if in wait_all_consoles()
154 error = tcsetpgrp(controlling_consinfo->fd, in wait_all_consoles()
158 controlling_consinfo->name); in wait_all_consoles()
183 if (consinfo->pid != -1) { in exit_signal_handler()
210 * NB: No need to check consinfo->pid as the caller is in sigchld_handler_reaped_one()
213 if (consinfo->pid == pid) in sigchld_handler_reaped_one()
215 else if (consinfo->pid != -1 && consinfo->pid != 0) in sigchld_handler_reaped_one()
222 child_consinfo->pid = 0; in sigchld_handler_reaped_one()
223 child_consinfo->exitstatus = status; in sigchld_handler_reaped_one()
243 while ((void)(pid = waitpid(-1, &status, WNOHANG)), in sigchld_handler()
244 pid != -1 && pid != 0) in sigchld_handler()
262 if (error == -1) in read_primary_console()
268 if (error == -1) in read_primary_console()
309 if ((tty->ty_status & TTY_ON) == 0) in read_consoles()
317 if (strncmp(tty->ty_name, "ttyv", 4) == 0 && in read_consoles()
318 strcmp(tty->ty_name + 4, "0") != 0) in read_consoles()
325 asprintf(&dev, "/dev/%s", tty->ty_name); in read_consoles()
331 if (fd == -1) in read_consoles()
335 if (flags == -1) in read_consoles()
339 if (error == -1) in read_consoles()
342 if (tcgetsid(fd) != -1) { in read_consoles()
348 if (pgrp == -1) in read_consoles()
358 controlling_consinfo->name, name); in read_consoles()
363 consinfo->name = name; in read_consoles()
364 consinfo->pid = -1; in read_consoles()
365 consinfo->fd = fd; in read_consoles()
366 consinfo->exitstatus = -1; in read_consoles()
370 strcmp(consinfo->name, primary_console) == 0) in read_consoles()
396 strcpy(primary_secondary, secondary); in start_console()
399 consinfo->name); in start_console()
402 if (pid == -1) in start_console()
411 * parent-only self-pipes, and might as well destroy the wait in start_console()
417 child_leader_run(consinfo->name, consinfo->fd, in start_console()
422 consinfo->pid = pid; in start_console()
460 * SIGKILL the children on timeout; do it up front so we can err if it in start_consoles()
464 * control of this terminal) handler before we start children so we can in start_consoles()
497 * Also ignore SIGTTOU so we can print errors if needed after the child in start_consoles()
518 * Create a fresh copy of the argument array and perform %-substitution; in start_consoles()
524 * either "primary" or "secondary" to it will yield the final argument in start_consoles()
531 primary_secondary = malloc(MAX(sizeof(primary), sizeof(secondary))); in start_consoles()
553 * consinfo->pid and, for the first iteration, calling err_set_exit, to in start_consoles()
554 * be atomic, and the child leader shouldn't have signals re-enabled in start_consoles()
584 return (first_sigchld_consinfo->exitstatus); in wait_consoles()
599 while ((ch = getopt_long(argc, argv, "+h", longopts, NULL)) != -1) { in main()
607 argc -= optind; in main()
624 * necessary (we ignore SIGTTOU so we can print errors, but don't want in main()