DirectNET

Data Center Management Solutions including UPS Systems, Data Center Cooling, KVM over IP & IP Power Strips, Server Racks and Server Rack accessories; KVM Switches and KVM Extenders; Rackmount Monitors and Rackmount Keyboards.


NAVIGATION
Home
Store
INSIDE MAC
Television Shows
Broadcast Shows
Daily News Shows
Special Shows
EVENTS
DAILY TIPS
Design
Mac OS X
Mac OS X UNIX
COMMUNITY
Forums
Surveys
NEWS
Current
Press
Archive
FEATURES
Editorial
Dr. Mac
Reviews
Reader Reports
RESOURCES
FAQ
Documentation
Learning Center
MAN pages
Glossary
Tutorials
Tips
Links

OUR PARTNERS


     #include <unistd.h>

     int
     execve(const char *path, char *const argv[], char *const envp[])


DESCRIPTION

     Execve() transforms the calling process into a new process.  The new pro-
     cess is constructed from an ordinary file, whose name is pointed to by
     path, called the new process file. This file is either an executable ob-
     ject file, or a file of data for an interpreter.  An executable object
     file consists of an identifying header, followed by pages of data repre-
     senting the initial program (text) and initialized data pages.  Addition-
     al pages may be specified by the header to be initialized with zero data;
     see a.out(5).

     An interpreter file begins with a line of the form:

           #! interpreter [arg]

     When an interpreter file is execve()'d, the system execve()'s runs the
     specified interpreter. If the optional arg is specified, it becomes the
     first argument to the interpreter, and the name of the originally
     execve()'d file becomes the second argument; otherwise, the name of the
     originally execve()'d file becomes the first argument.  The original ar-
     guments are shifted over to become the subsequent arguments.  The zeroth
     argument, normally the name of the execve()'d file, is left unchanged.

     The argument argv is a pointer to a null-terminated array of character
     pointers to null-terminated character strings.  These strings construct
     the argument list to be made available to the new process.  At least one
     argument must be present in the array; by custom, the first element
     should be the name of the executed program (for example, the last compo-
     nent of path).

     The argument envp is also a pointer to a null-terminated array of charac-
     ter pointers to null-terminated strings.  A pointer to this array is nor-
     mally stored in the global variable environ. These strings pass informa-
     tion to the new process that is not directly an argument to the command
     (see environ(7)).

     File descriptors open in the calling process image remain open in the new
     process image, except for those for which the close-on-exec flag is set
     (see close(2) and fcntl(2)).  Descriptors that remain open are unaffected
     by execve().

     Signals set to be ignored in the calling process are set to be ignored in
     the new process. Signals which are set to be caught in the calling pro-
     cess image are set to default action in the new process image.  Blocked
     signals remain blocked regardless of changes to the signal action.  The
     signal stack is reset to be undefined (see sigaction(2) for more informa-
     tion).

     process:

           process ID           see getpid(2)
           parent process ID    see getppid(2)
           process group ID     see getpgrp(2)
           access groups        see getgroups(2)
           working directory    see chdir(2)
           root directory       see chroot(2)
           control terminal     see termios(4)
           resource usages      see getrusage(2)
           interval timers      see getitimer(2)
           resource limits      see getrlimit(2)
           file mode mask       see umask(2)
           signal mask          see sigaction(2),  sigsetmask(2)

     When a program is executed as a result of an execve() call, it is entered
     as follows:

           main(argc, argv, envp)
           int argc;
           char **argv, **envp;

     where argc is the number of elements in argv (the ``arg count'') and argv
     points to the array of character pointers to the arguments themselves.


RETURN VALUES

     As the execve() function overlays the current process image with a new
     process image the successful call has no process to return to.  If
     execve() does return to the calling process an error has occurred; the
     return value will be -1 and the global variable errno is set to indicate
     the error.


ERRORS

     Execve() will fail and return to the calling process if:

     [ENOTDIR]     A component of the path prefix is not a directory.

     [ENAMETOOLONG]
                   A component of a pathname exceeded {NAME_MAX} characters,
                   or an entire path name exceeded {PATH_MAX} characters.

     [ENOENT]      The new process file does not exist.

     [ELOOP]       Too many symbolic links were encountered in translating the
                   pathname.

     [EACCES]      Search permission is denied for a component of the path
                   prefix.

     [EACCES]      The new process file is not an ordinary file.

     [EACCES]      The new process file mode denies execute permission.

     [E2BIG]       The number of bytes in the new process's argument list is
                   larger than the system-imposed limit.  The limit in the
                   system as released is 20480 bytes (NCARGS in
                   <sys/param.h>).

     [EFAULT]      The new process file is not as long as indicated by the
                   size values in its header.

     [EFAULT]      Path, argv, or envp point to an illegal address.

     [EIO]         An I/O error occurred while reading from the file system.


CAVEAT

     If a program is setuid to a non-super-user, but is executed when the real
     uid is ``root'', then the program has some of the powers of a super-user
     as well.


SEE ALSO

     exit(2),  fork(2),  execl(3),  environ(7)


HISTORY

     The execve() function call appeared in 4.2BSD.

4th Berkeley Distribution      January 24, 1994                              3

Copyright © 2000-2008 Inside Mac Media, Inc. All rights reserved.
Apple assumes no responsibility with regard to the selection, performance, or use of the products or services. All understandings, agreements, or warranties, if any, take place directly between the vendors and prospective users.
Apple, the Apple logo, Mac, PowerMac G4, PowerMac G5, Xserve, Xserve RAID, PowerBook, iBook, Airport, AirPort Extreme, iMac, eMac, iLife, iMovie, iCal, iPhoto, iTunes, QuickTime, FireWire, iPod, iSight, AppleWorks, Macintosh, Jaguar, Panther, Mac OS, Mac OS X and Mac OS X Server are trademarks of Apple Computer, Inc.