Contents

Dillo

Dillo

__Dillo_fork

Syntax

pid_t __Dillo_fork(const int* ChildIO, unsigned Flags)

Description

Basically a UNIX-like fork. You probably want to use __Dillo_fork2() (see section __Dillo_fork2) or __Dillo_spawn() (see section __Dillo_spawn) instead of this routine.

The caller may pass a pipes which will be used to communicate with the child process. -1 is used to indicate that the pipe's IO channel should not be employed. The pipe-ends are closed after forking. On fork failure all of the pipe ends are closed.

ChildIO is used to send and receive data with the child process; ChildIO[0] is read by the child, ChildIO[1] is written to by the child. Warning: this is not same as a what you would get from pipe(), but rather from two calls to pipe(). ChildIO is dup'd to `stdin', `stdout', `stderr', and then closed.

The child process has its SIGCHLD and SIGPIPE signals set to exit the child process.

Return Value

-1 on error, 0 if this is the child process, otherwise the process ID of the child if we are the parent.

See Also

__Dillo_fork2() (see section __Dillo_fork2), __Dillo_spawn() (see section __Dillo_spawn)

Cavaets

Profiling reveals that this is intensely slow. Don't fork unless you need to. We are the child... set ourselves up to die cleanly in case ofclose(ChildIO[0]);

__Dillo_fork2

Syntax

pid_t __Dillo_fork2(int* FileDes, unsigned Flags)

Description

Basically a UNIX-like fork.

A short note on how the child processes' IO is setup. The child process will write to its stdout IO channel. If Flags as the DILLO_NEWIN flag set, a new pipe will be created; the child process will read from its stdin IO channel. Otherwise, it is not defined here what the child will read from.

FileDes is set for the parent to communicate with the child; it is not set for the child process. FileDes[0] is used to read the childs output; it is set to be non-blocking, and close on exec().

If the DILLO_NEWIN flag is set, FileDes[1] can be used to to send data to the child. Otherwise FileDes[1] is set to a meaningless value.

If the DILLO_SHARE_ERR flag is set, the child's standard error is dup'd to its standard output. Otherwise, its standard error channel is the same as its parent.

If the DILLO_TTY flag is set, the child will be set to communicate using a master/slave pseudo-tty instead of standard pipe.

The child process has its SIGCHLD and SIGPIPE signals set to exit the child process.

Return Value

-1 on error, 0 if this is the child process, otherwise the process ID of the child if we are the parent.

See Also

__Dillo_fork() (see section __Dillo_fork), __Dillo_spawn() (see section __Dillo_spawn)

Cavaets

Profiling reveals that this is intensely slow. Don't fork unless you need to.

The child process may choose to fork again. This is done one linux systems when the DILLO_TTY flag is used, as a part of the mechanism to change controlling tty's.

__Dillo_spawn

Syntax

pid_t __Dillo_spawn(int* filedes, char* const ArgV[], char* const env[],
		  unsigned Flags)

Description

This spawns and executes a program. Name is the path of the program. env is the environment that the program should use.

If the DILLO_NEWIN flag is set, FileDes[1] can be used to to send data to the child. Otherwise FileDes[1] is set to a meaningless value.

If the DILLO_SHARE_ERR flag is set, the child's standard error is dup'd to its standard output. Otherwise, its standard error channel is the same as its parent.

If the DILLO_TTY flag is set, the child will be set to communicate using a master/slave pseudo-tty instead of standard pipe.

Return Value

-1 on error, otherwise the process id of the spawned task.


Author: Randall Maastop