mirror of
https://github.com/GnoConsortium/gno.git
synced 2024-06-06 22:29:28 +00:00
72 lines
1.5 KiB
Groff
72 lines
1.5 KiB
Groff
|
.TH FORK2 2
|
||
|
.SH NAME
|
||
|
fork2 \- start a new process from inside the current application
|
||
|
.SH SYNOPSIS
|
||
|
#include <unistd.h>
|
||
|
.sp 1
|
||
|
int
|
||
|
.BR fork2
|
||
|
.RI " (void *" proc ,
|
||
|
word
|
||
|
.IR stack ,
|
||
|
word
|
||
|
.IR prio ", char *" procname ,
|
||
|
word
|
||
|
.IR numargs ", ...);"
|
||
|
.SH DESCRIPTION
|
||
|
.B fork2
|
||
|
is similar to
|
||
|
.BR fork (2),
|
||
|
except that it allows more parameters to be passed than just function
|
||
|
which the child process will execute.
|
||
|
.LP
|
||
|
.I proc
|
||
|
is the name of the function at which the child process will begin execution.
|
||
|
.I stack
|
||
|
is the number of bytes of stack to allocate to the proess. If
|
||
|
.I stack
|
||
|
is not a multiple of 256, then it
|
||
|
is rounded up to the next highest multiple of 256 bytes.
|
||
|
.I prio
|
||
|
is the priority to assign to the process. Priorities are not currently
|
||
|
implemented, and you should pass 0 for this argument.
|
||
|
.I procname
|
||
|
is a string you can have associated with the process when viewing
|
||
|
the process table (See
|
||
|
.BR ps (1)).
|
||
|
.I numargs
|
||
|
is the number of
|
||
|
.B words
|
||
|
of arguments which follow, not the
|
||
|
number of arguments.
|
||
|
Any arguments following
|
||
|
.I numargs
|
||
|
are passed as parameters to the child's procedure.
|
||
|
.SH EXAMPLE
|
||
|
.nf
|
||
|
|
||
|
int main (int argc, char **argv) {
|
||
|
...
|
||
|
|
||
|
pid = fork2(proc1,1024,0,"sub-process",3,argc,argv);
|
||
|
...
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
void proc1(int argc, char *argv[])
|
||
|
{
|
||
|
...
|
||
|
}
|
||
|
|
||
|
.fi
|
||
|
.SH "RETURN VALUE"
|
||
|
.BR fork2
|
||
|
returns to the parent the process ID of the new process on success.
|
||
|
On failure, -1 is returned and
|
||
|
.B errno
|
||
|
is set.
|
||
|
.SH HISTORY
|
||
|
.B fork2
|
||
|
first appeared in XINU.
|