Lines Matching refs:process

42  * init(1M) is the general process spawning program.  Its primary job is to
72 * Because init(1M) no longer governs the startup process, its knowledge of
91 #include <sys/contract/process.h>
258 #define OFF 0 /* Kill process if on, else ignore */
259 #define RESPAWN 1 /* Continuously restart process when it dies */
261 #define ONCE 2 /* Start process, do not respawn when dead */
310 /* process */
316 short p_exit; /* Exit status of a process which died */
327 * if process is dead.
329 * NAMED This process has a name, i.e. came from inittab.
361 * respawn a process SPAWN_LIMIT times before it gets mad.
386 /* process to be affected by */
388 short c_levels; /* Mask of legal levels for process */
479 static const int init_num_proc = 20; /* Initial size of process table. */
749 * Here is the beginning of the main process loop.
992 * there is a process in the table, which shouldn't be here at
993 * the current run level, then remv() kills the process.
998 struct PROC_TABLE *process;
1010 for (process = proc_table;
1011 (process < proc_table + num_proc); process++) {
1012 process->p_flags &= ~TOUCHED;
1019 /* Scan for process which goes with this entry in inittab. */
1020 for (process = proc_table;
1021 (process < proc_table + num_proc); process++) {
1022 if ((process->p_flags & OCCUPIED) == 0 ||
1023 !id_eq(process->p_id, cmd.c_id))
1027 * This slot contains the process we are looking for.
1031 * Is the cur_state SINGLE_USER or is this process
1034 * does not support this process?
1039 (process->p_flags & DEMANDREQUEST) == 0)) {
1040 if (process->p_flags & LIVING) {
1050 process->p_flags |= TOUCHED;
1052 if ((process->p_flags & KILLED) == 0) {
1054 process->p_flags
1057 process->p_pid,
1068 process->p_pid);
1070 process->p_flags |= KILLED;
1083 if (process->p_flags &
1085 process->p_flags |= TOUCHED;
1096 * process table for processes that were warned to die. If any
1114 for (process = proc_table;
1115 (process < proc_table + num_proc); process++) {
1117 * If this process should die, hasn't yet, and the
1118 * TWARN time hasn't expired yet, wait for process
1122 (process->p_flags & (WARNED|LIVING|OCCUPIED)) ==
1138 for (process = proc_table;
1139 (process < proc_table + num_proc); process++) {
1140 if ((process->p_flags &
1143 (void) kill(process->p_pid, SIGKILL);
1156 for (process = proc_table;
1157 (process < proc_table + num_proc); process++) {
1158 if ((process->p_flags & (LIVING|NAMED|TOUCHED|KILLED|OCCUPIED))
1160 killproc(process->p_pid);
1161 process->p_flags |= KILLED;
1162 } else if ((process->p_flags & (LIVING|NAMED|OCCUPIED)) ==
1164 (void) account(DEAD_PROCESS, process, NULL);
1171 if ((process->p_flags & TOUCHED) == 0)
1172 process->p_flags = 0;
1247 * Find out if there is a process slot for this entry already.
1268 * mode, and the process is dead, then respawn it.
1301 * a process and not waiting, and spinning off a process and
1303 * ONDEMAND, POWERFAIL, or BOOT we don't wait for the process
1321 * spawn() spawns a shell, inserts the information about the process
1322 * process into the proc_table, and does the startup accounting.
1325 spawn(struct PROC_TABLE *process, struct CMD_LINE *cmd)
1338 if (process->p_flags & DEMANDREQUEST || cur_state == LVLa ||
1345 * If this is a respawnable process, check the threshold
1361 if (process->p_time == 0L)
1362 process->p_time = now;
1364 if (process->p_count++ == SPAWN_LIMIT) {
1366 if ((now - process->p_time) < SPAWN_INTERVAL) {
1377 process->p_time = now;
1378 process->p_count = 0;
1380 } else if (process->p_count > SPAWN_LIMIT) {
1382 * If process has been respawning too rapidly and
1386 if (now - process->p_time < SPAWN_INTERVAL + INHIBIT)
1388 process->p_time = now;
1389 process->p_count = 0;
1395 * Spawn a child process to execute this command.
1398 oprocess = process;
1399 while ((process = efork(cmd->c_action, oprocess, modes)) == NO_ROOM)
1402 if (process == NULLPROC) {
1412 * Perform the accounting for the beginning of a process.
1449 process->p_id[0] = cmd->c_id[0];
1450 process->p_id[1] = cmd->c_id[1];
1451 process->p_id[2] = cmd->c_id[2];
1452 process->p_id[3] = cmd->c_id[3];
1460 * findpslot() finds the old slot in the process table for the
1466 struct PROC_TABLE *process;
1469 for (process = proc_table;
1470 (process < proc_table + num_proc); process++) {
1471 if (process->p_flags & OCCUPIED &&
1472 id_eq(process->p_id, cmd->c_id))
1480 if (empty == NULLPROC && (process->p_flags & OCCUPIED) == 0) {
1481 empty = process;
1482 process->p_id[0] = '\0';
1483 process->p_id[1] = '\0';
1484 process->p_id[2] = '\0';
1485 process->p_id[3] = '\0';
1486 process->p_pid = 0;
1487 process->p_time = 0L;
1488 process->p_count = 0;
1489 process->p_flags = 0;
1490 process->p_exit = 0;
1500 if (process == (proc_table + num_proc))
1501 process = empty;
1503 return (process);
1610 /* yet reached the shell command field, process */
1889 * killproc() creates a child which kills the process specified by pid.
1894 struct PROC_TABLE *process;
1897 while ((process = efork(M_OFF, NULLPROC, 0)) == NO_ROOM)
1901 if (process == NULLPROC) {
1909 * We are the child. Try to terminate the process nicely
2048 struct PROC_TABLE *process, *oprocess;
2062 * Scan inittab(4) and process the special svc.startd entry, initdefault
2085 if (process = findpslot(&cmd)) {
2099 for (oprocess = process;
2100 (process = efork(M_OFF, oprocess,
2106 if (process == NULLPROC) {
2120 while (waitproc(process) == FAILURE)
2122 process->p_flags = 0;
2270 struct PROC_TABLE *process;
2315 * Clear all times and repeat counts in the process table
2321 for (process = proc_table;
2322 (process < proc_table + num_proc); process++) {
2323 process->p_time = 0L;
2324 process->p_count = 0;
2365 struct PROC_TABLE *process;
2369 * Scan the process table to see if we are interested in this process.
2371 for (process = proc_table;
2372 (process < proc_table + num_proc); process++) {
2373 if ((process->p_flags & (LIVING|OCCUPIED)) ==
2374 (LIVING|OCCUPIED) && process->p_pid == pid) {
2377 * Mark this process as having died and store the exit
2381 process->p_flags &= ~LIVING;
2382 process->p_exit = (short)status;
2390 * No process was found above, look through auxiliary list.
2440 * efork() forks a child and the parent inserts the process in its table
2442 * The child just changes the "global" with the process id for this process
2454 efork(int action, struct PROC_TABLE *process, int modes)
2467 * Is this a named process?
2483 * and free up a slot in the process table.
2500 if (process == NULLPROC) {
2505 for (process = proc_table; process->p_flags != 0 &&
2506 (process < proc_table + num_proc); process++)
2509 if (process == (proc_table + num_proc)) {
2512 /* Increase the process table size */
2518 process =
2523 process->p_time = 0L;
2524 process->p_count = 0;
2526 process->p_id[0] = '\0';
2527 process->p_id[1] = '\0';
2528 process->p_id[2] = '\0';
2529 process->p_id[3] = '\0';
2530 process->p_pid = childpid;
2531 process->p_flags = (LIVING | OCCUPIED | modes);
2532 process->p_exit = 0;
2539 process = NULLPROC;
2560 return (process);
2565 * waitproc() waits for a specified process to die. For this function to
2566 * work, the specified process must already in the proc_table. waitproc()
2567 * returns the exit status of the specified process when it dies.
2570 waitproc(struct PROC_TABLE *process)
2585 * Wait around until the process dies.
2587 if (process->p_flags & LIVING)
2594 if (process->p_flags & LIVING)
2599 * be positive whenever the process of interest really died.
2601 answer = (process->p_exit & 0xffff);
2606 process->p_flags = 0;
2660 account(short state, struct PROC_TABLE *process, char *program)
2680 u->ut_id[0] = process->p_id[0];
2681 u->ut_id[1] = process->p_id[1];
2682 u->ut_id[2] = process->p_id[2];
2683 u->ut_id[3] = process->p_id[3];
2684 u->ut_pid = process->p_pid;
2689 u->ut_exit.e_termination = WTERMSIG(process->p_exit);
2690 u->ut_exit.e_exit = WEXITSTATUS(process->p_exit);
3512 * Function to handle requests from users to main init running as process 1.
3541 * Make sure this process is talking to a legal tty line
4086 fd = open64(CTFS_ROOT "/process/template", O_RDWR);
4090 console(B_TRUE, "Couldn't create process template: %s.\n",
4184 fd = open64(CTFS_ROOT "/process/pbundle", O_RDONLY);
4189 "Couldn't open process pbundle: %s. Core smf(5) services "
4195 console(B_TRUE, "Could not duplicate process bundle: %s.\n",
4218 fd = contract_open(id, "process", name, oflag);
4284 "Unknown poll error on my process contract "
4559 * one_true_init, the process initially contains the audit
4560 * characteristics of the process that invoked init. The first pass