4 * Copyright (C) 2009 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 // Utility functions for all the forking classes
35 virtual ~ForkWrapper();
37 // Can't start in the constructor because it'll erase the subclass constructor.
39 // Called by subclass to send a command to exit the loop
41 // Use the fd of another fork already in progress.
42 // Used to transfer a parent ForkWrapper from 1 process to another.
43 void start_dummy(int parent_fd, int pid);
45 virtual void init_child();
46 virtual int handle_command();
47 // return 1 if the child is running
49 // Return 1 if the child is dead
50 int read_timeout(unsigned char *data, int size);
54 // Called by parent to send commands
55 int send_command(int token,
58 // Called by child to get commands
60 // Called by parent to read result
61 int64_t read_result();
62 // Called by child to send result
63 int send_result(int64_t value, unsigned char *data, int data_size);
64 // Called by child to send a file descriptor
66 // Called by parent to get a file descriptor
75 unsigned char *command_data;
77 int command_allocated;
80 unsigned char *result_data;