1 /* process.h -- header for child process routines for vlock,
2 * the VT locking program for linux
4 * This program is copyright (C) 2007 Frank Benkstein, and is free
5 * software which is freely distributable under the terms of the
6 * GNU General Public License version 2, included as the file COPYING in this
7 * distribution. It is NOT public domain software, and any
8 * redistribution not permitted by the GNU General Public License is
9 * expressly forbidden without prior written permission from
17 #include <sys/types.h>
21 #define VLOCK_PROCESS_ERROR vlock_process_error_quark()
22 GQuark
vlock_process_error_quark(void);
25 VLOCK_PROCESS_ERROR_FAILED
,
26 VLOCK_PROCESS_ERROR_NOT_FOUND
,
29 /* Wait for the given amount of time for the death of the given child process.
30 * If the child process dies in the given amount of time or already was dead
31 * true is returned and false otherwise. */
32 bool wait_for_death(pid_t pid
, long sec
, long usec
);
34 /* Try hard to kill the given child process. */
35 void ensure_death(pid_t pid
);
37 #define NO_REDIRECT (-2)
38 #define REDIRECT_DEV_NULL (-3)
39 #define REDIRECT_PIPE (-4)
43 /* Function that will be run in the child. */
44 int (*function
)(void *argument
);
45 /* Argument for the function. */
47 /* First argument to execv. */
49 /* Second argument to execv. */
50 const char *const *argv
;
51 /* The child's stdin. */
53 /* The child's stdout. */
55 /* The child's stderr. */
57 /* The child's PID. */
61 /* Create a new child process. All file descriptors except stdin, stdout and
62 * stderr are closed and privileges are dropped. All fields of the child
63 * struct except pid must be set. If a stdio file descriptor field has the
64 * special value of REDIRECT_DEV_NULL it is redirected from or to /dev/null.
65 * If it has the value REDIRECT_PIPE a pipe will be created and one end will be
66 * connected to the respective descriptor of the child. The file descriptor of
67 * the other end is stored in the field after the call. It is up to the caller
68 * to close the pipe descriptor(s). */
69 bool create_child(struct child_process
*child
, GError
**error
);