4
Common helper functions to be used in child processes
7
Sumit Bose <sbose@redhat.com>
9
Copyright (C) 2009 Red Hat
11
This program is free software; you can redistribute it and/or modify
12
it under the terms of the GNU General Public License as published by
13
the Free Software Foundation; either version 3 of the License, or
14
(at your option) any later version.
16
This program is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
GNU General Public License for more details.
21
You should have received a copy of the GNU General Public License
22
along with this program. If not, see <http://www.gnu.org/licenses/>.
25
#ifndef __CHILD_COMMON_H__
26
#define __CHILD_COMMON_H__
29
#include <sys/types.h>
33
#include "util/util.h"
35
#define IN_BUF_SIZE 512
36
#define MAX_CHILD_MSG_SIZE 255
49
/* Async communication with the child process via a pipe */
50
struct tevent_req *write_pipe_send(TALLOC_CTX *mem_ctx,
51
struct tevent_context *ev,
52
uint8_t *buf, size_t len, int fd);
53
int write_pipe_recv(struct tevent_req *req);
55
struct tevent_req *read_pipe_send(TALLOC_CTX *mem_ctx,
56
struct tevent_context *ev, int fd);
57
int read_pipe_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
58
uint8_t **buf, ssize_t *len);
60
/* The pipes to communicate with the child must be nonblocking */
61
void fd_nonblocking(int fd);
63
void child_sig_handler(struct tevent_context *ev,
64
struct tevent_signal *sige, int signum,
65
int count, void *__siginfo, void *pvt);
67
errno_t exec_child(TALLOC_CTX *mem_ctx,
68
int *pipefd_to_child, int *pipefd_from_child,
69
const char *binary, int debug_fd);
71
void child_cleanup(int readfd, int writefd);
73
#endif /* __CHILD_COMMON_H__ */