GNU Pies Manual (split by chapter):   Section:   Chapter:FastBack: piesctl   Up: Top   FastForward: Configuration Examples   Contents: Table of ContentsIndex: Concept Index

6 Init – parent of all processes

Pies can be executed directly by the kernel as a program responsible for starting all other processes (a process with PID 1). In this case it becomes also the parent of all processes whose natural parents have died and is responsible for reaping those when they die.

When invoked this way, pies reads its configuration from two files: /etc/inittab and /etc/pies.init. The former has traditional syntax (see inittab) and is retained for compatibility with another ‘init’ daemons, and the latter is in native pies format (see Syntax). Either of the files or even both of them can be missing.

The startup process passes through several states. Transition between states is controlled by runlevel, which also defines the set of components that must be executed. Startup states are:


System initialization state. This state marks the beginning of the startup process. Only root partition is mounted, and is usually read-only. Pies uses console to output diagnostic messages.

Normally, the configuration instructs pies to execute at this point the system initialization script, which checks and mounts the necessary local file systems, initializes devices and loads kernel modules.

The system then passes to ‘boot’ state, unless the default runlevel is ‘S’, in which case the ‘single’ state is selected.


Upon entering the ‘boot’ state, pies attempts to log the ‘reboot’ login record into the system utmp/wtmp files and executes entries marked with boot and bootwait types. It then enters the ‘normal’ state.


This is a fallback state for single-user system. It is entered only if the ‘S’ runlevel has been selected initially. Normally, this state is used for system maintenance. The configuration usually provides a component which executes a single-user shell when entering this state. If it does not, pies executes ‘/sbin/sulogin’.


Upon entering this state, pies assumes that components executed previously have brought the system to such condition where normal communication means can already be used. This means that the file systems have been mounted read-write and the syslog daemon is operating. Therefore pies opens its communication channels and redirects its diagnostic output to syslog facility ‘daemon’.

Then it starts components scheduled for the default runlevel and begins its normal operation.

Pies communication channels are:


A FIFO file for communication using legacy protocol (using telinit).


UNIX socket for communication using piesctl.

6.1 Runlevels

Runlevel determines the set of components to be run in normal state. It is a decimal digit from ‘0’ to ‘9’ or letter ‘S’. Traditionally, runlevels are assigned as follows:


System halt.


Single user mode.


Multiuser mode.


Multiuser with X11.

Additionally, three special runlevels ‘a’, ‘b’ and ‘c’ can be used to start on-demand components without actually changing the runlevel. Once started, on-demand components persist through eventual runlevel changes.

6.2 Init Process Configuration

The two configuration files are read in this order: /etc/inittab first, then /etc/pies.init. The /etc/inittab file is a simple line-oriented file. Empty lines and lines beginning with ‘#’ are ignored (except if ‘#’ is followed by the word ‘pies’, see below). Non-empty lines consist of 4 fields separated by colons:




Component identifier. A string uniquely identifying this component.


List of the runlevels for which the component should be run. Runlevels are listed as a contiguous string of characters, without any whitespace or delimiters.


Component execution mode.


Command to be executed and its arguments.

Component execution modes are:


The basic execution mode. A respawn component is restarted each time it terminates. If it is restarted more than 10 times in 2 minutes, pies puts it in sleeping state for the next 5 minutes.


Disabled component. The entry is ignored.


The process will be executed during system boot. The ‘runlevel’ settings are ignored.


The process will be executed during system boot. No other components will be started until it has terminated. The ‘runlevel’ settings are ignored.


The process will be executed during system boot, before any boot or bootwait entries. The ‘runlevel’ settings are ignored.


The process will be executed once when the specified runlevel is entered.


The process will be started once when the specified runlevel is entered. Pies will wait for its termination before starting any other processes.


The process will be executed when pies receives the SIGINT signal. Normally this means that the CTRL-ALT-DEL combination has been pressed on the keyboard.


The process will be executed when a signal from the keyboard handler is received that indicates that a special key combination was pressed on the console keyboard.


The process will be executed when the specified ondemand runlevel is called (‘a’, ‘b’ and ‘c’). No real runlevel change will occur (see Ondemand runlevels). The process will remain running across any eventual runlevel changes and will be restarted whenever it terminates, similarly to respawn components.


The process will be executed when the power goes down. Pies will not wait for the process to finish.


The process will be executed when the power is failing and the battery of the external UPS is almost empty.


The process will be executed as soon as pies is informed that the power has been restored.


The process will be executed when the power goes down. Pies will wait for the process to finish before continuing.

The special mode ‘initdefault’ declares the default runlevel. In the ‘initdefault’ entry, the runlevels field must consist of exactly one runlevel character. Rest of fields are ignored. For example, the following instructs pies that the default runlevel is ‘3’:


If no ‘initdefault’ entry is present, pies will ask the user to input the desired default runlevel upon entering the normal state.

Inittab must contain at least one entry with ‘S’ in runlevels field. This entry is used for system maintenance and recovery. If it is absent, pies adds the following default entry implicitly:


As an exception to traditional syntax, the ‘#’ followed by the word ‘pies’ (with any amount of white space in between) introduce a pragmatic comment that modifies the behavior of the configuration parser. The following such comments are understood:

#pies pragma debug n

Set debugging level n (a decimal number). See Pies Debugging.

#pies pragma next syntax file

After parsing /etc/inittab, read configuration from file file, assuming syntax (see config syntax). Multiple ‘next’ pragmas are allowed, the named files will be processed in turn.

The default set up is equivalent to specifying

#pies pragma next pies /etc/pies.init
#pies pragma stop

Stop parsing after this line. The remaining material is ignored.

Both the traditional /etc/inittab and pies-native /etc/pies.init files are entirely equivalent, excepting that, naturally, the latter is more flexible and gives much more possibilities in defining the system behavior. The declaration of a component in /etc/pies.init can contain all the statements discussed in Component Statement. The only difference is that runlevels to start the component is must be specified:

Config: component: runlevels string

Specifies the runlevel to start the component in. The string argument is a string of runlevel characters.

For example, the inittab entry discussed above is equivalent to the following statement in pies.init file:

component id {
  mode mode;
  runlevels runlevels;
  command command;

The default runlevel is specified in /etc/pies.init using the following construct:

Config: initdefault rl

Declare the default runlevel. The argument is the runlevel name. E.g.

initdefault 3;

If both /etc/inittab and /etc/pies.init are present, the latter can declare components with the same id as the ones declared in the former. In that case, the two entries will be merged, the latter one overriding the former. Thus, /etc/pies.init can be used to complement definitions in inittab. Consider, for example the following inittab entry:


If pies.init contains the following:

component upd {
    user nobody;
    stderr syslog local1;

the result will be equivalent to:

component upd {
    mode respawn;
    runlevels 3;
    command /usr/libexec/upload;
    user nobody;
    stderr syslog local1;

6.3 Init Command Line

The runlevel to run in can be given as argument in the command line:

/sbin/pies 1

Apart from this, the following command line arguments are recognized:


Initialize default runlevel ‘S’.


Run emergency shell /sbin/sulogin, prior to initialization.

6.4 Init Environment

Programs run from pies init process inherit a basic environment consisting of the following variables:


Previous runlevel, or letter ‘N’ if the runlevel hasn’t been changed since startup.


Current runlevel.


Pathname of the console device file.


Version of pies.


Once the system is booted up, the environment can be controlled using the piesctl telinit environ (or pies -T -e) command.

6.5 piesctl telinit

piesctl: piesctl telinit runlevel

Report the runlevel and state of the process 1.

piesctl: piesctl telinit runlevel n

Switch to runlevel n.

piesctl: piesctl telinit environ list [NAME]

List the environment. If NAME is given, list only the value of that variable.

piesctl: piesctl telinit environ set NAME=VALUE

Set variable NAME to VALUE. The environment is capable to hold at most 32 variables.

piesctl: piesctl telinit environ unset NAME

Unset variable NAME.

6.6 The Telinit Command

When given the -T (--telinit) option, pies emulates the behavior of the traditional telinit command. This is a legacy way of communicating with the init process. The commands are sent via named pipe /dev/initctl. When the -T option is given, the rest of command line after it is handled as telinit options. The following command:

pies -T [-t n] r

tells init process to switch to runlevel r. Possible values for r are:

0 to 9

Instructs init to switch to the specified runlevel.

S or s

Tells init to switch to the single user mode.

a, b, or c

Tells init to enable on-demand components with the specified runlevel. The actual runlevel is not changed.

Q or q

Tells init to rescan configuration files.

The -t (--timeout) option sets the time to wait for processes to terminate after sending them the SIGTERM signal. Any processes that remain running after n seconds will be sent the SIGKILL signal. The default value is 5 seconds.

This usage is equivalent to the piesctl telinit runlevel command (see piesctl telinit).

The -e (--environment) option modifies the init process environment. Its argument is either a variable assignment ‘name=value’ to set a variable, or the name of a variable to unset it. Several -e options can be given to process multiple variables in a single command. Note, however, that given n -e options, the total length of their arguments is limited to 367 - n bytes.

This option provides a limited subset of the functionality offered by the piesctl telinit environ command.

The table below summarizes all options available in telinit mode:

-t n

Wait n seconds for processes to terminate after sending them the SIGTERM signal. Any processes that remain running after that time will be sent the SIGKILL signal. The default value is 5 seconds.

-e var=value

Define environment variable var as having value value.

-e var

Unset environment variable var.

GNU Pies Manual (split by chapter):   Section:   Chapter:FastBack: Init Process   Up: Init Process   FastForward: Configuration Examples   Contents: Table of ContentsIndex: Concept Index