8 * Copyright (C) 2001-2003 FhG Fokus
10 * Permission to use, copy, modify, and distribute this software for any
11 * purpose with or without fee is hereby granted, provided that the above
12 * copyright notice and this permission notice appear in all copies.
14 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 * 2003-04-15 added tcp_disable support (andrei)
26 * 2006-06-14 added process table in shared mem (dragos)
27 * 2007-07-04 added register_fds() and get_max_open_fds(() (andrei)
29 /** internal fork functions and process table.
38 #include <sys/types.h>
44 #include "socket_info.h"
47 #define MAX_PT_DESC 128
49 struct process_table {
52 int unix_sock; /* unix socket on which tcp main listens */
53 int idx; /* tcp child index, -1 for other processes */
55 char desc[MAX_PT_DESC];
58 extern struct process_table *pt;
59 extern gen_lock_t* process_lock;
60 extern int *process_count;
61 extern int process_no;
63 extern struct tcp_child* tcp_children;
65 int init_pt(int proc_no);
67 int register_procs(int no);
68 int get_max_open_fds();
69 int register_fds(int no);
72 int close_extra_socks(int proc_id, int proc_no);
74 #define get_proc_no() ((process_count)?*process_count:0)
76 /* return processes pid */
80 * Forks a new process.
81 * @param desc - text description for the process table
82 * @param make_sock - if to create a unix socket pair for it
83 * @returns the pid of the new process
85 int fork_process(int child_id,char *desc,int make_sock);
88 * Forks a new TCP process.
89 * @param desc - text description for the process table
90 * @param r - index in the tcp_children array
91 * @param *reader_fd_1 - pointer to return the reader_fd[1]
92 * @returns the pid of the new process
95 int fork_tcp_process(int child_id,char *desc,int r,int *reader_fd_1);
99 void mem_dump_pkg_cb(str *gname, str *name);
103 int mem_dump_shm_fixup(void *handle, str *gname, str *name, void **val);