gno/usr.man/man3/exec.3

82 lines
1.6 KiB
Groff

.\"
.\" $Id: exec.3,v 1.1 1997/02/27 07:32:22 gdr Exp $
.\"
.TH EXEC 3 "19 January 1997" GNO "Library Routines"
.SH NAME
.BR exec
\- load an executable file and launch as a new process
.SH SYNOPSIS
#include <unistd.h>
.sp 1
int
\fBexec\fR(const char *\fIpathname\fR, const char *\fIcmdline\fR);
.SH DESCRIPTION
This call is provided only for backward compatibility and should be
avoided. New programs should use the
.BR execve (2)
family of calls, the
.BR system (3)
routine, or the
.BR EXECUTE
shell call.
.LP
.BR exec
is an alternative method for launching a new process under GNO.
It is a combination of the
.BR fork (2)
and
.BR _execve (2)
system calls, and is in fact written in terms of them. The difference
between
.BR exec
and
.BR _execve
is that
.BR exec
returns in all cases; it is a simplified interface for those who don't
need to affect process information before a new executable begins
(such as process group IDs or I/O redirection information).
.LP
The (somewhat simplified) algorithm for
.BR exec
is as follows:
.RS
.nf
void exec2() {
return _execve();
}
int exec() {
return fork(exec2);
}
.fi
.RE
.SH RETURN VALUE
.BR exec
returns the process ID of the child, or -1 (and setting
.BR errno )
if an error occurs in either the
.BR fork
or
.BR _execve
call.
.SH BUGS
See the BUGS section in the
.BR execve (2)
man page.
.LP
If an error occurs in the
.BR _execve
phase of this call, it can only be detected with the
.BR wait (2)
system call; it will get the return code of the process, which will be -1
if the
.BR _execve
fails.
.SH SEE ALSO
.BR execve (2),
.BR fork (2),
.BR wait (2),
.BR execl (3),
.BR system (3).