Description
  The
t_bunny_subprocess serve two purpose: the first one is to be
filled with boolean values to indicates to
bunny_popen which inputs and outputs to create.
The second one is to retrieve file descriptor that match those inputs and outputs.
The
pid field is ignored on the first step, but return the forked processed
pid on the second one.
Attributes
-
pid_t pid:
  The pid of the forked process. This attribute is an output.
-
int stdin:
  Send true or false to open or not a pipe between
a file descriptor that will be stored in this attribute in the main
program and the stdin of the forked program.
-
int stdout:
  Send true or false to open or not a pipe between
a file descriptor that will be stored in this attribute in the main
program and the stdout of the forked program.
-
int stderr:
  Send true or false to open or not a pipe between
a file descriptor that will be stored in this attribute in the main
program and the stderr of the forked program.
-
int custom_data_input:
  Send true or false to open or not a pipe between
a file descriptor that will be stored in this attribute in the main
program and the input file descriptor 3 of the forked program.
The file descriptor value may be different on forked program side,
depending of previously opened file descriptor.
The only guarantee LibLapin give you is that bunny_popen decriptors value
are following eachother depending of which one you required.
-
int custom_data_output:
  Send true or false to open or not a pipe between
a file descriptor that will be stored in this attribute in the main
program and the output file descriptor 4 of the forked program.
The file descriptor value may be different on forked program side,
depending of previously opened file descriptor.
The only guarantee LibLapin give you is that bunny_popen decriptors value
are following eachother depending of which one you required.
-
int custom_command_input:
  Send true or false to open or not a pipe between
a file descriptor that will be stored in this attribute in the main
program and the input file descriptor 5 of the forked program.
The file descriptor value may be different on forked program side,
depending of previously opened file descriptor.
The only guarantee LibLapin give you is that bunny_popen decriptors value
are following eachother depending of which one you required.
-
int custom_command_output:
  Send true or false to open or not a pipe between
a file descriptor that will be stored in this attribute in the main
program and the output file descriptor 6 of the forked program.
The file descriptor value may be different on forked program side,
depending of previously opened file descriptor.
The only guarantee LibLapin give you is that bunny_popen decriptors value
are following eachother depending of which one you required.
INDEX
Description
  The
bunny_popen function opens a process and creates several pipes
as required. Pipes are unidirectional but they are several so you can
create complex communications if needed.
The subprocess and associated communications must be ended with
bunny_pclose.
Parameters
-
t_bunny_subprocess *subproc:
  A structure that configure the way the communication will be established
between the main process and the new one. The pid of the children will be stored
inside the structure after the process forked. true fields will be overwritten
by file descriptor values of opened pipes.
-
char **environ:
  The environment of the newly created process.
-
size_t nbr_param:
  The amount of parameters sent in the variadic part of the function.
-
...:
Variadic parameters. Parameters sent here are command line like: the first
parameter is the command, other parameters are the command parameter. For example:
ls -l -a
Will become:
bunny_popen( ... , 3, "ls", "-l", "-a");
Return value
-
On success, the function returns the pid of the created process.
-
On failure, it returns -1.
Error values and logs
On error, bunny_errno is set to:
-
EMFILE:
The per-process limit on the number of open file descriptors has been reached.
-
ENFILE:
The system-wide limit on the total number of open files has been reached.
-
EAGAIN:
A system-imposed limit on the number of threads was encountered.
-
ENOSYS:
fork() is not supported on this platform
-
ENOMEM:
Out of memory.
Logs written by this function are tagged with the "unix" label.
INDEX
Description
  The
bunny_pclose close communication and end a subprogram (if not already terminated)
after the sent delay. It may return faster if the program end before the delay is
consumed.
If the delay is consumed, a SIGINT is sent to the process with the pid stored inside
subproc.
Parameters
-
t_bunny_subprocess *subproc:
  A structure that store the pid of the process to terminate and
file descriptor of opened communications.
-
int delay_in_seconds:
  The delay before killing the subprocess with SIGINT.
Return value
-
If the subprocess was terminate correctly, the function returns its return value.
-
If the subprocess was killed, the function return 0.
INDEX