Blame gettext-tools/gnulib-lib/wait-process.h

Packit 5b56b6
/* Waiting for a subprocess to finish.
Packit 5b56b6
   Copyright (C) 2001-2003, 2006, 2008-2015 Free Software Foundation, Inc.
Packit 5b56b6
   Written by Bruno Haible <haible@clisp.cons.org>, 2001.
Packit 5b56b6
Packit 5b56b6
   This program is free software: you can redistribute it and/or modify
Packit 5b56b6
   it under the terms of the GNU General Public License as published by
Packit 5b56b6
   the Free Software Foundation; either version 3 of the License, or
Packit 5b56b6
   (at your option) any later version.
Packit 5b56b6
Packit 5b56b6
   This program is distributed in the hope that it will be useful,
Packit 5b56b6
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 5b56b6
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 5b56b6
   GNU General Public License for more details.
Packit 5b56b6
Packit 5b56b6
   You should have received a copy of the GNU General Public License
Packit 5b56b6
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit 5b56b6
Packit 5b56b6
#ifndef _WAIT_PROCESS_H
Packit 5b56b6
#define _WAIT_PROCESS_H
Packit 5b56b6
Packit 5b56b6
/* Get pid_t.  */
Packit 5b56b6
#include <stdlib.h>
Packit 5b56b6
#include <unistd.h>
Packit 5b56b6
#include <sys/types.h>
Packit 5b56b6
Packit 5b56b6
#include <stdbool.h>
Packit 5b56b6
Packit 5b56b6
Packit 5b56b6
#ifdef __cplusplus
Packit 5b56b6
extern "C" {
Packit 5b56b6
#endif
Packit 5b56b6
Packit 5b56b6
Packit 5b56b6
/* Wait for a subprocess to finish.  Return its exit code.
Packit 5b56b6
   If it didn't terminate correctly, exit if exit_on_error is true, otherwise
Packit 5b56b6
   return 127.
Packit 5b56b6
   Arguments:
Packit 5b56b6
   - child is the pid of the subprocess.
Packit 5b56b6
   - progname is the name of the program executed by the subprocess, used for
Packit 5b56b6
     error messages.
Packit 5b56b6
   - If ignore_sigpipe is true, consider a subprocess termination due to
Packit 5b56b6
     SIGPIPE as equivalent to a success.  This is suitable for processes whose
Packit 5b56b6
     only purpose is to write to standard output.  This flag can be safely set
Packit 5b56b6
     to false when the process' standard output is known to go to DEV_NULL.
Packit 5b56b6
   - If null_stderr is true, the usual error message to stderr will be omitted.
Packit 5b56b6
     This is suitable when the subprocess does not fulfill an important task.
Packit 5b56b6
   - slave_process should be set to true if the process has been launched as a
Packit 5b56b6
     slave process.
Packit 5b56b6
   - If exit_on_error is true, any error will cause the main process to exit
Packit 5b56b6
     with an error status.
Packit 5b56b6
   - If termsigp is not NULL: *termsig will be set to the signal that
Packit 5b56b6
     terminated the subprocess (if supported by the platform: not on native
Packit 5b56b6
     Windows platforms), otherwise 0, and the error message about the signal
Packit 5b56b6
     that terminated the subprocess will be omitted.
Packit 5b56b6
   Prerequisites: The signal handler for SIGCHLD should not be set to SIG_IGN,
Packit 5b56b6
   otherwise this function will not work.  */
Packit 5b56b6
extern int wait_subprocess (pid_t child, const char *progname,
Packit 5b56b6
                            bool ignore_sigpipe, bool null_stderr,
Packit 5b56b6
                            bool slave_process, bool exit_on_error,
Packit 5b56b6
                            int *termsigp);
Packit 5b56b6
Packit 5b56b6
/* Register a subprocess as being a slave process.  This means that the
Packit 5b56b6
   subprocess will be terminated when its creator receives a catchable fatal
Packit 5b56b6
   signal or exits normally.  Registration ends when wait_subprocess()
Packit 5b56b6
   notices that the subprocess has exited.  */
Packit 5b56b6
extern void register_slave_subprocess (pid_t child);
Packit 5b56b6
Packit 5b56b6
Packit 5b56b6
#ifdef __cplusplus
Packit 5b56b6
}
Packit 5b56b6
#endif
Packit 5b56b6
Packit 5b56b6
Packit 5b56b6
#endif /* _WAIT_PROCESS_H */