STARTPROC(8)
β¨ STARTPROC(8) β¨
ok so this is the STARTPROC(8) page from The SuSE boot concept β and it's literally the whole "is it running? no? then start it" pipeline bestie π
πΈ NAME πΈ
Startprocβ start processes identified by path nameStart_daemonβ start processes identified by path name
(yes they're the same thing, start_daemon is just the LSB-flavored twin π«Ά)
β SYNOPSIS β
startproc [-fLves] [-x] [[-n ]-<prio>] [-o c<class>,n<data>]
[-(t|T) <sec>] [-u user] [-g group] [-l log_file|-q|-d]
[-p pid_file] [-i ignore_file] [-c root] [-(w|W <file list>)]
/path/to/executable [arguments for executable]
start_daemon [-fLve] [-x] [-n +/-<prio>] [-o c<class>,n<data>] [-u user]
[-g group] [-l log_file|-q|-d] [-p pid_file] [-i ignore_file]
[-c root] /path/to/executable [arguments for executable]
π¦ SYNOPSIS LSB 3.1 π¦
start_daemon [-f] [-n +/-<prio>] /path/to/executable [arguments for
executable]
π DESCRIPTION π
ok so here's the whole vibe: startproc and the LSB variant start_daemon go check for all the processes of the executable you named, and if they find none, they start it. periodt. π
β οΈ real talk though: startproc is designed to start a daemon β not a kernel thread, and not a program that enables a kernel thread. it's giving "wrong tool for that job" energy, and you don't wanna find out the hard way π
With no options at all, startproc hunts for a process using the full path of the corresponding program plus a default pid file (/var/run/<basename>.pid) β those two together identify the executable out from the /proc file system (see proc(5)). And it only falls back to the base name (/proc/<pid>/stat) to identify the running program if the inode number (/proc/<pid>/exe) and the full name are unavailable (/proc/<pid>/cmdline), or if the executable straight up changes its zeroth argument π
The extra-sparkle functionality comes from -p (this used to be option -f, but it changed due to the LSB specification, iykyk). If you pass it, startproc tries to check against the pid read from that file instead of the default pid file (/var/run/<basename>.pid). The pid read from the file gets compared against the pids of possible running processes that use the specified executable. And to avoid confusion with stale pid files, a not-up-to-date pid is justβ¦ ignored π
So you can have two different sessions of one binary program? yeah β option -i ignore_file lets you specify a pid file whose pid number is used to ignore all processes of the corresponding process session. iconic behavior honestly π
And option -v makes startproc print out verbose diagnostics, because sometimes you just need the tea β
Now the thing about start_daemon: it does not support -(t|T) <sec> or -(w|W <file list>) for waiting for success, and it doesn't do -s for a new session β because this variant doesn't fork to start the executable. no fork, no drama, no those flags π
π₯ REQUIRED π₯
/path/to/executableβ specifies the executable by its full path name, and this argument is always required, no exceptions bestie. Everything that follows this path is considered options for the executable being launched. Want more info? hit up the respectivemanpage(s)π
β¨ OPTIONS β¨
[-n ]+/-<prio>β set the nice level for the process. If you use it, this option should always be the first in the command line, don't fight it. The nice level<prio>may be specified in the range between-20and+20. And heads up: only root is allowed to set negative nice values π-o c<class>,n<data>β set the io scheduling class and priority. If used, this option requires the class identifiercand the class number to use:0for none,1for realtime,2for best-effort,3for idle. The scheduling class data can be appended with the identifiern. This only has an effect if the chosen class accepts an argument. For the classes realtime and best-effort,0upto7are valid data numbers β lower number = higher priority, so don't come for the small numbers β‘-eβ bequeath only a minimal set of environment variables to the new process:HOME,PATH,SHELL,LISTEN_PID,LISTEN_FDS,RUNLEVEL, andPREVLEVEL. travel light π-p pid_fileβ (former option-f, changed due to the LSB specification.) Use an alternate pid file instead of the default (/var/run/<basename>.pid). The pid read from this file is being matched against the pid of running processes that have an executable with the specified path. In order to avoid confusion with stale pid files, a not up-to-date pid will be ignored. Obviously this option does not work if option-fis specified π«-i ignore_fileβ the pid found in this file is used as session id of the same binary program, which should be ignored bystartproc. Obviously this option does not work if option-fis specified π«-fβ this option is required by the Linux Standard Base Specification (LSB). With this option the start of a process is forced. no thoughts, just force π€-g groupβ sets the group ID of the process togid.-l log_fileβ redirect the process standard output and standard error to the filelog_file. bye bye terminal spam π«Ά-Lβ this option causes symlinks to be followed, as the like-named option inls(1). Note: for the file name the original name of the program is used instead of the name of the symbolic link π-c rootβ change root directory toroot. Services which have been started with this option can only be checked bycheckproc(8)and signaled bykillproc(8)ifcheckproc(8)andkillproc(8)are called with the same option argument for the option-c. consistency is key bestie ποΈ-qβ equals to-l /dev/null(supresses output). shhh π€«-dβ letstartprocexpect that the started service will do a dialog by prompting for, e.g. a passphrase. This option implies a timeout of15seconds (-t 15) β³-sβ starts the process in a new session. The new task is a process group leader and has no controlling tty π-t <sec>β the number of seconds to wait after the successful start of a service. This option accepts the number of seconds to wait. You can specify some units after a given number:sfor seconds,mfor minutes, andhfor hours to wait β±οΈ-T <sec>β the same as for option-tbut wait only on the started process, not on childs forked by the process πΆ-wβ wait the first started process to terminate before returning. If the parent process of the daemon does not finish, alsostartproc(8)does not finish. clingy but make it sysadmin π-W <file list>β wait on the provided file or list of files separated with colons. If the files will not be created,startproc(8)does not finish π°οΈ-u userβ sets the user ID of the process touser.-vβ verbose output. tell me everything π¬-xβ tellsstartprocas well asstart_daemonto use the upto 15 byte long filename name found in/proc/<pid>/statto be able to identify scripts overwriting their command line π
π EXAMPLE π
startproc /usr/sbin/sendmail
starts /usr/sbin/sendmail if no sendmail process is found. If a pid file sendmail.pid exists in /var/run/, then the pid found in this file is used to search the process table for a process with an executable that matches the specified pathname, /usr/sbin/sendmail. If no matching process is found, /usr/sbin/sendmail is launched π
startproc -p /var/myrun/lpd.pid /usr/sbin/lpd
starts /usr/sbin/lpd if there is no process with the pid found in /var/myrun/lpd.pid and no process in the actual process table exists that uses the specified binary. double-checked, double-slay π
β¨
π EXIT CODES π
The exit codes have the following LSB conform conditions:
0β Success π1β Generic or unspecified error2β Invalid or excess argument(s)4β Insufficient privilege(s)5β Program is not installed7β Program is not running
In some error cases, diagnostic output is sent to standard error, or, if standard error is not available, syslogd(8) is being used π¨
π‘ NOTE π‘
startproc is a replacement for the Bourne shell function daemon found in the widely used SysVinit package of Miquel van Smoorenburg, <miquels@cistron.nl>. And repeat after me: startproc is not useful to start kernel threads π
ββοΈ That should be done by service utilities designed for the purpose to accomplish this task. use the right tool, bestie.
π BUGS π
ok so the caveats, and there are a few, ngl:
- Identifying a process based on the executable file and the corresponding inode number only works if the process stays alive during
startproc's execution. Processes rewriting their zeroth argument, or shell scripts (the inode number of the shell executable file is not identical to that of the script file), may not be identified by a filename path π¬ Startprocdoes not start a process if there already exists one being in the zombie state. Zombies are processes which arn't alive but listed in the process table to have the exit status ready for the corresponding parent processes. Therefore the parent processes should be check out π§Start_daemonis not able to check for exit status of an executable daemon, because after the finalexecve(3)thestart_daemonas an own process does not exit anymore π«₯
ποΈ FILES ποΈ
/proc/β path to the proc file system (seeproc(5))./etc/init.d/β path to the SuSE boot concept script base directory as required by the Linux Standard Base Specification (LSB) (seeinit.d(7)).
π SEE ALSO π
checkproc(8), killproc(8), insserv(8), init.d(7), kill(1), skill(1), killall(8), killall5(8), signal(7), proc(5).
go read those too, they're the friend group π«Ά
π COPYRIGHT π
1994-2007 Werner Fink, 1996-2000 SuSE GmbH Nuernberg, Germany. 2007 SuSE LINUX Products GmbH, Nuernberg, Germany.
π§ AUTHOR π§
Werner Fink <werner@suse.de>
and that's the whole page bestie π this one came from the 3rd Berkeley Distribution, dated Nov 30, 2007, and it's filed under STARTPROC(8) β now go start some daemons, responsibly πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: sysvinit-tools-doc 3.14-160000.2.2 Β· GPL-2.0-or-later
- Copyright (c) 1994-2007 Werner Fink, 1996-2000 SuSE GmbH, Nuernberg, Germany
- Copyright (c) 2007 SuSE LINUX Products GmbH, Nuernberg, Germany
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms