diff options
| author | Mattias Andrée <maandree@member.fsf.org> | 2015-12-28 15:07:11 +0100 | 
|---|---|---|
| committer | Mattias Andrée <maandree@member.fsf.org> | 2015-12-28 15:07:11 +0100 | 
| commit | ae79d159182044ad450f6c189c231f7ddbbdc918 (patch) | |
| tree | 0bfe787fdae24a298ca6b8c640074f324d1b2417 /include | |
| parent | fix errors (diff) | |
| download | slibc-ae79d159182044ad450f6c189c231f7ddbbdc918.tar.gz slibc-ae79d159182044ad450f6c189c231f7ddbbdc918.tar.bz2 slibc-ae79d159182044ad450f6c189c231f7ddbbdc918.tar.xz  | |
daemonise: support keeping arbitrary fd:s open
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/unistd.h | 23 | 
1 files changed, 22 insertions, 1 deletions
diff --git a/include/unistd.h b/include/unistd.h index f4d699c..29a65c6 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -1076,6 +1076,12 @@ int daemon(int, int)  #define DAEMONISE_KEEP_STDOUT  512  /** + * Enables you to select additional + * file descritors to keep open. + */ +#define DAEMONISE_KEEP_FDS  1024 + +/**   * Daemonise the process. This means to:   *    * -  close all file descritors except for those to @@ -1156,25 +1162,40 @@ int daemon(int, int)   *                 -  `DAEMONISE_CLOSE_STDERR`   *                 -  `DAEMONISE_KEEP_STDIN`   *                 -  `DAEMONISE_KEEP_STDOUT` + *                 -  `DAEMONISE_KEEP_FDS` + * @parma   ...    Enabled if `DAEMONISE_KEEP_FDS` is used, + *                 do not add anything if `DAEMONISE_KEEP_FDS` + *                 is unused. This is a `-1`-terminated list + *                 of file descritors to keep open. 0, 1, and 2 + *                 are implied by `DAEMONISE_KEEP_STDIN`, + *                 `DAEMONISE_KEEP_STDOUT`, and `DAEMONISE_KEEP_STDERR`, + *                 respectively. All arguments are of type `int`.   * @return         Zero on success, -1 on error.   *    * @throws  EEXIST  The PID file already exists on the system.   *                  Unless your daemon supervisor removs old   *                  PID files, this could mean that the daemon   *                  has exited without removing the PID file. + * @throws  EINVAL  `flags` contains an unsupported bit, both + *                  `DAEMONISE_KEEP_STDERR` and `DAEMONISE_CLOSE_STDERR` + *                  are set, or both `DAEMONISE_CLOSE_STDERR` and + *                  `DAEMONISE_KEEP_FDS` are set whilst `2` is + *                  in the list of file descriptor not to close.   * @throws          Any error specified for signal(3).   * @throws          Any error specified for sigemptyset(3).   * @throws          Any error specified for sigprocmask(3).   * @throws          Any error specified for chdir(3).   * @throws          Any error specified for pipe(3). + * @throws          Any error specified for dup(3).   * @throws          Any error specified for dup2(3).   * @throws          Any error specified for fork(3).   * @throws          Any error specified for setsid(3).   * @throws          Any error specified for open(3). + * @throws          Any error specified for malloc(3).   *    * @since  Always.   */ -int daemonise(const char*, int) +int daemonise(const char*, int, ...)    __GCC_ONLY(__attribute__((__nonnull__, __warn_unused_result__)));  /**  | 
