root/maint/gnulib/lib/wait-process.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /* Waiting for a subprocess to finish.
   2    Copyright (C) 2001-2003, 2006, 2008-2021 Free Software Foundation, Inc.
   3    Written by Bruno Haible <haible@clisp.cons.org>, 2001.
   4 
   5    This program is free software: you can redistribute it and/or modify
   6    it under the terms of the GNU General Public License as published by
   7    the Free Software Foundation; either version 3 of the License, or
   8    (at your option) any later version.
   9 
  10    This program is distributed in the hope that it will be useful,
  11    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13    GNU General Public License for more details.
  14 
  15    You should have received a copy of the GNU General Public License
  16    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
  17 
  18 #ifndef _WAIT_PROCESS_H
  19 #define _WAIT_PROCESS_H
  20 
  21 /* Get pid_t.  */
  22 #include <stdlib.h>
  23 #include <unistd.h>
  24 #include <sys/types.h>
  25 
  26 #include <stdbool.h>
  27 
  28 
  29 #ifdef __cplusplus
  30 extern "C" {
  31 #endif
  32 
  33 
  34 /* Wait for a subprocess to finish.  Return its exit code.
  35    If it didn't terminate correctly, exit if exit_on_error is true, otherwise
  36    return 127.
  37    Arguments:
  38    - child is the pid of the subprocess.
  39    - progname is the name of the program executed by the subprocess, used for
  40      error messages.
  41    - If ignore_sigpipe is true, consider a subprocess termination due to
  42      SIGPIPE as equivalent to a success.  This is suitable for processes whose
  43      only purpose is to write to standard output.  This flag can be safely set
  44      to false when the process' standard output is known to go to DEV_NULL.
  45    - If null_stderr is true, the usual error message to stderr will be omitted.
  46      This is suitable when the subprocess does not fulfill an important task.
  47    - slave_process should be set to true if the process has been launched as a
  48      slave process.
  49    - If exit_on_error is true, any error will cause the main process to exit
  50      with an error status.
  51    - If termsigp is not NULL: *termsig will be set to the signal that
  52      terminated the subprocess (if supported by the platform: not on native
  53      Windows platforms), otherwise 0, and the error message about the signal
  54      that terminated the subprocess will be omitted.
  55    Prerequisites: The signal handler for SIGCHLD should not be set to SIG_IGN,
  56    otherwise this function will not work.  */
  57 extern int wait_subprocess (pid_t child, const char *progname,
  58                             bool ignore_sigpipe, bool null_stderr,
  59                             bool slave_process, bool exit_on_error,
  60                             int *termsigp);
  61 
  62 /* Register a subprocess as being a slave process.  This means that the
  63    subprocess will be terminated when its creator receives a catchable fatal
  64    signal or exits normally.  Registration ends when wait_subprocess()
  65    notices that the subprocess has exited.  */
  66 extern void register_slave_subprocess (pid_t child);
  67 
  68 
  69 #ifdef __cplusplus
  70 }
  71 #endif
  72 
  73 
  74 #endif /* _WAIT_PROCESS_H */

/* [previous][next][first][last][top][bottom][index][help] */