Include -Wunreachable-code when building.
[sysvinit.git] / src / init.h
CommitLineData
a74aeac6
PR
1/*
2 * init.h Several defines and declarations to be
3 * included by all modules of the init program.
4 *
5 * Version: @(#)init.h 2.85-5 02-Jul-2003 miquels@cistron.nl
6 *
7 * Copyright (C) 1998-2003 Miquel van Smoorenburg.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 *
23 */
24
25/* Standard configuration */
26#define CHANGE_WAIT 0 /* Change runlevel while
27 waiting for a process to exit? */
28/* Debug and test modes */
29#define DEBUG 0 /* Debug code off */
30#define INITDEBUG 0 /* Fork at startup to debug init. */
31
32/* Some constants */
33#define INITPID 1 /* pid of first process */
34#define PIPE_FD 10 /* Fileno of initfifo. */
35#define STATE_PIPE 11 /* used to pass state through exec */
36
37/* Failsafe configuration */
38#define MAXSPAWN 10 /* Max times respawned in.. */
39#define TESTTIME 120 /* this much seconds */
40#define SLEEPTIME 300 /* Disable time */
41
42/* Default path inherited by every child. */
43#define PATH_DEFAULT "/sbin:/usr/sbin:/bin:/usr/bin"
44
45
46/* Prototypes. */
47void write_utmp_wtmp(char *user, char *id, int pid, int type, char *line);
48void write_wtmp(char *user, char *id, int pid, int type, char *line);
49#ifdef __GNUC__
50__attribute__ ((format (printf, 2, 3)))
51#endif
52void initlog(int loglevel, char *fmt, ...);
53void set_term(int how);
54void print(char *fmt);
55
901fc4d2
PR
56/* from dowall.c */
57void wall(const char *text, int remote);
58
a74aeac6
PR
59#if DEBUG
60# define INITDBG(level, fmt, args...) initlog(level, fmt, ##args)
61#else
62# define INITDBG(level, fmt, args...)
63#endif
64
65/* Actions to be taken by init */
66#define RESPAWN 1
67#define WAIT 2
68#define ONCE 3
69#define BOOT 4
70#define BOOTWAIT 5
71#define POWERFAIL 6
72#define POWERWAIT 7
73#define POWEROKWAIT 8
74#define CTRLALTDEL 9
75#define OFF 10
76#define ONDEMAND 11
77#define INITDEFAULT 12
78#define SYSINIT 13
79#define POWERFAILNOW 14
80#define KBREQUEST 15
81
82/* Information about a process in the in-core inittab */
83typedef struct _child_ {
84 int flags; /* Status of this entry */
85 int exstat; /* Exit status of process */
86 int pid; /* Pid of this process */
87 time_t tm; /* When respawned last */
88 int count; /* Times respawned in the last 2 minutes */
89 char id[8]; /* Inittab id (must be unique) */
90 char rlevel[12]; /* run levels */
91 int action; /* what to do (see list below) */
92 char process[128]; /* The command line */
93 struct _child_ *new; /* New entry (after inittab re-read) */
94 struct _child_ *next; /* For the linked list */
95} CHILD;
96
97/* Values for the 'flags' field */
98#define RUNNING 2 /* Process is still running */
99#define KILLME 4 /* Kill this process */
100#define DEMAND 8 /* "runlevels" a b c */
101#define FAILING 16 /* process respawns rapidly */
102#define WAITING 32 /* We're waiting for this process */
103#define ZOMBIE 64 /* This process is already dead */
104#define XECUTED 128 /* Set if spawned once or more times */
105
106/* Log levels. */
107#define L_CO 1 /* Log on the console. */
108#define L_SY 2 /* Log with syslog() */
109#define L_VB (L_CO|L_SY) /* Log with both. */
110
111#ifndef NO_PROCESS
112# define NO_PROCESS 0
113#endif
114
115/*
116 * Global variables.
117 */
118extern CHILD *family;
119extern int wrote_wtmp_reboot;
120extern int wrote_utmp_reboot;
63a2c981
DWF
121extern int wrote_wtmp_rlevel;
122extern int wrote_utmp_rlevel;
123extern char thislevel;
124extern char prevlevel;
a74aeac6
PR
125
126/* Tokens in state parser */
127#define C_VER 1
128#define C_END 2
129#define C_REC 3
130#define C_EOR 4
131#define C_LEV 5
132#define C_FLAG 6
133#define C_ACTION 7
134#define C_PROCESS 8
135#define C_PID 9
136#define C_EXS 10
137#define C_EOF -1
138#define D_RUNLEVEL -2
139#define D_THISLEVEL -3
140#define D_PREVLEVEL -4
141#define D_GOTSIGN -5
142#define D_WROTE_WTMP_REBOOT -6
143#define D_WROTE_UTMP_REBOOT -7
144#define D_SLTIME -8
145#define D_DIDBOOT -9
63a2c981
DWF
146#define D_WROTE_WTMP_RLEVEL -16
147#define D_WROTE_UTMP_RLEVEL -17
a74aeac6 148