{"id":19634095,"url":"https://github.com/raforg/daemon","last_synced_at":"2025-09-03T12:38:13.248Z","repository":{"id":48786093,"uuid":"311983644","full_name":"raforg/daemon","owner":"raforg","description":"turns other processes into daemons","archived":false,"fork":false,"pushed_at":"2023-08-24T12:57:19.000Z","size":1444,"stargazers_count":18,"open_issues_count":4,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-25T03:48:40.131Z","etag":null,"topics":["bsd","c","cli","daemon","daemonize","debian","freebsd","linux","macos","macosx","netbsd","openbsd","posix","redhat","svr4","ubuntu","unix"],"latest_commit_sha":null,"homepage":"http://libslack.org/daemon/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raforg.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-11T13:46:55.000Z","updated_at":"2025-06-04T23:47:51.000Z","dependencies_parsed_at":"2024-11-11T12:30:07.607Z","dependency_job_id":null,"html_url":"https://github.com/raforg/daemon","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/raforg/daemon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raforg%2Fdaemon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raforg%2Fdaemon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raforg%2Fdaemon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raforg%2Fdaemon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raforg","download_url":"https://codeload.github.com/raforg/daemon/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raforg%2Fdaemon/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272289707,"owners_count":24907802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-27T02:00:09.397Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bsd","c","cli","daemon","daemonize","debian","freebsd","linux","macos","macosx","netbsd","openbsd","posix","redhat","svr4","ubuntu","unix"],"created_at":"2024-11-11T12:19:32.365Z","updated_at":"2025-08-27T04:16:53.148Z","avatar_url":"https://github.com/raforg.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"README\n======\n*daemon* - turns other processes into daemons\n\nDESCRIPTION\n===========\n*Daemon* turns other processes into daemons. There are many tasks that need to\nbe performed to correctly set up a daemon process. This can be tedious.\n*Daemon* performs these tasks for other processes. This is useful for writing\ndaemons in languages other than *C*, *C++* or *Perl* (e.g. `/bin/sh`, *Java*).\n\nIf you want to write daemons in languages that can link against *C* functions\n(e.g. *C*, *C++*), see *libslack* which contains the core functionality of *daemon*.\n\nDETAILS\n=======\n*Daemon* turns other processes into daemons. There are many tasks that need to\nbe performed to correctly set up a daemon process. This can be tedious.\n*Daemon* performs these tasks for other processes.\n\nThe preparatory tasks that *daemon* performs for other processes are:\n\nFirst revoke any setuid or setgid privileges that *daemon* may have been\ninstalled with (by system administrators who laugh in the face of danger).\n\nProcess command line options.\n\nChange the root directory if the `--chroot` option was supplied.\n\nChange the process `uid` and `gid` if the `--user` option was supplied. Only\n*root* can use this option. Note that the `uid` of *daemon* itself is changed,\nrather than just changing the `uid` of the client process.\n\nRead the system configuration file(s) (`/etc/daemon.conf` and\n`/etc/daemon.conf.d/*` by default, or specified by the `--config` option)\nunless the `--noconfig` option was supplied. Then read the user's personal\nconfiguration file(s) (`~/.daemonrc` and `~/.daemonrc.d/*`), if any. Note:\nThe root directory and the user must be set before access to the\nconfiguration file(s) can be attempted so neither `--chroot` nor `--user`\noptions may appear in the configuration file.\n\nOn *BSD* systems (except *macOS*), the system configuration file(s) are\n`/usr/local/etc/daemon.conf` and `/usr/local/etc/daemon.conf.d/*` by\ndefault.\n\nOn *macOS*, when installed via *macports*, the system configuration file(s)\nare `/opt/local/etc/daemon.conf` and `/opt/local/etc/daemon.conf.d/*`.\n\nDisable core file generation to prevent leaking potentially sensitive\ninformation in daemons that are run by *root* (unless the `--core` option\nwas supplied).\n\nBecome a daemon process:\n\n  * If *daemon* was not invoked by *init(8)* (i.e. pid 1) or *inetd(8)*:\n\n    * Ignore `SIGHUP` signals in case the current process session leader\n      terminates while attached to a controlling terminal, causing us to\n      receive a `SIGHUP` signal before we start our own process session below.\n      This can happen when *daemon* was invoked interactively via the shell\n      builtin `exec`. When this initial process terminates below, the terminal\n      emulator that invoked the shell also terminates, so *daemon* needs to\n\t  protect itself from that.\n\n    * Background the process to lose process group leadership.\n\n    * Start a new process session.\n\n\t* Background the process again to lose process session leadership. Under\n\t  *SVR4* this prevents the process from ever gaining a controlling\n\t  terminal. This is only necessary under *SVR4*, but is always done for\n\t  simplicity. Note that ignoring `SIGHUP` signals earlier means that\n\t  when the newly created process session leader terminates, then even if\n\t  it has a controlling terminal open, the newly backgrounded process\n\t  won't receive the corresponding `SIGHUP` signal that is sent to all\n\t  processes in the process session's foreground process group, because\n\t  it inherited signal dispositions from the initial process.\n\n  * Change the current directory to the root directory so as not to hamper\n    umounts.\n\n  * Clear the *umask* to enable explicit file creation modes.\n\n  * Close all open file descriptors. If *daemon* was invoked by *inetd(8)*,\n\t`stdin`, `stdout` and `stderr` are left open, because they are open to a\n\tsocket.\n\n  * Open `stdin`, `stdout` and `stderr` to `/dev/null`, in case something\n    requires them to be open. Of course, this is not done if *daemon* was\n    invoked by *inetd(8)*.\n\n  * If the `--name` option was supplied, create and lock a file containing the\n\tprocess id of the *daemon* process. The presence of this locked file\n\tprevents two instances of a daemon with the same name from running at\n\tthe same time. The default location of the pidfile is `/var/run` for\n\t*root* (`/etc` on *Solaris*, `/opt/local/var/run` on *macOS* when\n\tinstalled via *macports*), and `/tmp` for normal users. If the\n\t`--pidfiles` option was supplied, its argument specifies the directory\n\tin which the pidfile will be placed. If the `--pidfile` option was\n\tsupplied, its argument specifies the name of the pidfile and the\n\tdirectory in which it will be placed.\n\nIf the `--umask` option was supplied, set the *umask* to its argument, which\nmust be a valid three-digit octal mode. Otherwise, set the *umask* to `022`,\nto prevent accidentally creating group- or world-writable files.\n\nSet the current directory if the `--chdir` option was supplied.\n\nSpawn the client command and wait for it to terminate. The client command\ncan be specified as command line arguments, or as the argument of the\n`--command` option. If both the `--command` option and command line\narguments are present, the client command is the result of appending the\ncommand line arguments to the argument of the `--command` option.\n\nIf the `--output`, `--stdout` and/or `--stderr` option were supplied, the client's\nstandard output and/or standard error are captured by *daemon*, and sent to the\nrespective *syslog* destinations.\n\nWhen the client terminates, *daemon* respawns it if the `--respawn` option\nwas supplied. If the client ran for less than `300` seconds (or the value of\nthe `--acceptable` option), then *daemon* sees this as a failure. It will\nattempt to restart the client up to five times (or the value of the\n`--attempts` option), before waiting for `300` seconds (or the value of the\n`--delay` option). This gives the system administrator the chance to correct\nwhatever is preventing the client from running successfully without\noverloading system resources. If the `--limit` option was supplied, *daemon*\nterminates after the specified number of respawn attempt bursts. The default\nis zero, which means never give up, never surrender.\n\nWhen the client terminates, and the `--respawn` option wasn't supplied,\n*daemon* terminates as well.\n\nIf the `--foreground` option was supplied, the client process is run as a\nforeground process, and is not turned into a daemon at all. If *daemon* is\nconnected to a terminal, then the client process will also be connected to\nit. If *daemon* is not connected to a terminal, but the client needs to be\nconnected to a terminal, use the `--pty` option.\n\nIf the `--bind` option was supplied, on systems with *systemd-logind* or\n*elogind*, the client process will be terminated when the user logs out.\n\nThe `--stop` option sends a `SIGTERM` signal to a currently running named\n*daemon*, which causes it to terminate its client process (with a `SIGTERM`\nsignal), and to then terminate itself.\n\nThe `--restart` option sends a `SIGUSR1` signal to a currently running named\n*daemon*, which causes it to terminate its client process (with a `SIGTERM`\nsignal). If the named *daemon* was started with the `--respawn` option, it\nwill then restart the client. Otherwise, it will terminate itself.\n\nThe `--signal` option sends a user-specified signal directly to a currently\nrunning named *daemon*'s client process.\n\nThe `--running` option reports whether or not a given named *daemon* process\nis currently running.\n\nThe `--list` option reports all the currently running named *daemon* processes.\n\n--------------------------------------------------------------------------------\n\n    URL: https://libslack.org/daemon\n    URL: https://raf.org/daemon\n    GIT: https://github.com/raforg/daemon\n    GIT: https://codeberg.org/raforg/daemon\n    Date: 20230824\n    Author: raf \u003craf@raf.org\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraforg%2Fdaemon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraforg%2Fdaemon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraforg%2Fdaemon/lists"}