Blame support/subprocess.h

Packit Bot 40fc07
/* Create a subprocess.
Packit Bot 40fc07
   Copyright (C) 2019 Free Software Foundation, Inc.
Packit Bot 40fc07
   This file is part of the GNU C Library.
Packit Bot 40fc07
Packit Bot 40fc07
   The GNU C Library is free software; you can redistribute it and/or
Packit Bot 40fc07
   modify it under the terms of the GNU Lesser General Public
Packit Bot 40fc07
   License as published by the Free Software Foundation; either
Packit Bot 40fc07
   version 2.1 of the License, or (at your option) any later version.
Packit Bot 40fc07
Packit Bot 40fc07
   The GNU C Library is distributed in the hope that it will be useful,
Packit Bot 40fc07
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Bot 40fc07
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Bot 40fc07
   Lesser General Public License for more details.
Packit Bot 40fc07
Packit Bot 40fc07
   You should have received a copy of the GNU Lesser General Public
Packit Bot 40fc07
   License along with the GNU C Library; if not, see
Packit Bot 40fc07
   <http://www.gnu.org/licenses/>.  */
Packit Bot 40fc07
Packit Bot 40fc07
#ifndef SUPPORT_SUBPROCESS_H
Packit Bot 40fc07
#define SUPPORT_SUBPROCESS_H
Packit Bot 40fc07
Packit Bot 40fc07
#include <sys/types.h>
Packit Bot 40fc07
Packit Bot 40fc07
struct support_subprocess
Packit Bot 40fc07
{
Packit Bot 40fc07
  int stdout_pipe[2];
Packit Bot 40fc07
  int stderr_pipe[2];
Packit Bot 40fc07
  pid_t pid;
Packit Bot 40fc07
};
Packit Bot 40fc07
Packit Bot 40fc07
/* Invoke CALLBACK (CLOSURE) in a subprocess created with fork and return
Packit Bot 40fc07
   its PID, a pipe redirected to STDOUT, and a pipe redirected to STDERR.  */
Packit Bot 40fc07
struct support_subprocess support_subprocess
Packit Bot 40fc07
  (void (*callback) (void *), void *closure);
Packit Bot 40fc07
Packit Bot 40fc07
/* Issue FILE with ARGV arguments by using posix_spawn and return is PID, a
Packit Bot 40fc07
   pipe redirected to STDOUT, and a pipe redirected to STDERR.  */
Packit Bot 40fc07
struct support_subprocess support_subprogram
Packit Bot 40fc07
  (const char *file, char *const argv[]);
Packit Bot 40fc07
Packit Bot 40fc07
/* Wait for the subprocess indicated by PROC::PID.  Return the status
Packit Bot 40fc07
   indicate by waitpid call.  */
Packit Bot 40fc07
int support_process_wait (struct support_subprocess *proc);
Packit Bot 40fc07
Packit Bot 40fc07
/* Terminate the subprocess indicated by PROC::PID, first with a SIGTERM and
Packit Bot 40fc07
   then with a SIGKILL.  Return the status as for waitpid call.  */
Packit Bot 40fc07
int support_process_terminate (struct support_subprocess *proc);
Packit Bot 40fc07
Packit Bot 40fc07
#endif