4.3BSD-Reno/share/man/cat2/execve.0

Compare this file to the similar file:
Show the results in this format:




EXECVE(2)		      1988			EXECVE(2)



NNAAMMEE
     execve - execute a file

SSYYNNOOPPSSIISS
     eexxeeccvvee((ppaatthh,, aarrggvv,, eennvvpp))
     cchhaarr **ppaatthh,, ****aarrggvv,, ****eennvvpp;;

DDEESSCCRRIIPPTTIIOONN
     _E_x_e_c_v_e transforms the calling process into a new process.
     The new process is constructed from an ordinary file, whose
     name is pointed to by _p_a_t_h, called the _n_e_w _p_r_o_c_e_s_s _f_i_l_e.
     This file is either an executable object file, or a file of
     data for an interpreter.  An executable object file consists
     of an identifying header, followed by pages of data
     representing the initial program (text) and initialized data
     pages.  Additional pages may be specified by the header to
     be initialized with zero data.  See _a._o_u_t(5).

     An interpreter file begins with a line of the form ``##!!
     _i_n_t_e_r_p_r_e_t_e_r [[_a_r_g]]''.  When an interpreter file is _e_x_e_c_v_e'd,
     the system _e_x_e_c_v_e's the specified _i_n_t_e_r_p_r_e_t_e_r.  If the
     optional _a_r_g is specified, it becomes the first argument to
     the _i_n_t_e_r_p_r_e_t_e_r, and the name of the originally eexxeeccvvee'd
     file becomes the second argument; otherwise, the name of the
     originally eexxeeccvvee'd file becomes the first argument.  The
     original arguments are shifted over to become the subsequent
     arguments.  The zeroth argument, normally the name of the
     eexxeeccvvee'd file, is left unchanged.

     There can be no return from a successful _e_x_e_c_v_e because the
     calling core image is lost.  This is the mechanism whereby
     different process images become active.

     The argument _a_r_g_v is a pointer to a null-terminated array of
     character pointers to null-terminated character strings.
     These strings constitute the argument list to be made avail-
     able to the new process.  By convention, at least one argu-
     ment must be present in this array, and the first element of
     this array should be the name of the executed program (i.e.,
     the last component of _p_a_t_h).

     The argument _e_n_v_p is also a pointer to a null-terminated
     array of character pointers to null-terminated strings.
     These strings pass information to the new process that is
     not directly an argument to the command (see _e_n_v_i_r_o_n(7)).

     Descriptors open in the calling process remain open in the
     new process, except for those for which the close-on-exec
     flag is set (see _c_l_o_s_e(2) and _f_c_n_t_l(2)).  Descriptors that
     remain open are unaffected by _e_x_e_c_v_e.





Printed 7/27/90             November				1






EXECVE(2)		      1988			EXECVE(2)



     Ignored signals remain ignored across an _e_x_e_c_v_e, but signals
     that are caught are reset to their default values.  Blocked
     signals remain blocked regardless of changes to the signal
     action.  The signal stack is reset to be undefined (see
     _s_i_g_v_e_c(2) for more information).

     Each process has _r_e_a_l user and group IDs and an _e_f_f_e_c_t_i_v_e
     user and group IDs.  The _r_e_a_l ID identifies the person using
     the system; the _e_f_f_e_c_t_i_v_e ID determines his access
     privileges.  _E_x_e_c_v_e changes the effective user and group ID
     to the owner of the executed file if the file has the "set-
     user-ID" or "set-group-ID" modes.	The _r_e_a_l user and group
     IDs are not affected.

     The new process also inherits the following attributes from
     the calling process:

	  process ID	      see _g_e_t_p_i_d(2)
	  parent process ID   see _g_e_t_p_p_i_d(2)
	  process group ID    see _g_e_t_p_g_r_p(2)
	  access groups       see _g_e_t_g_r_o_u_p_s(2)
	  working directory   see _c_h_d_i_r(2)
	  root directory      see _c_h_r_o_o_t(2)
	  control terminal    see _t_t_y(4)
	  resource usages     see _g_e_t_r_u_s_a_g_e(2)
	  interval timers     see _g_e_t_i_t_i_m_e_r(2)
	  resource limits     see _g_e_t_r_l_i_m_i_t(2)
	  file mode mask      see _u_m_a_s_k(2)
	  signal mask	      see _s_i_g_v_e_c(2), _s_i_g_s_e_t_m_a_s_k(2)

     When the executed program begins, it is called as follows:

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

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

     _E_n_v_p is a pointer to an array of strings that constitute the
     _e_n_v_i_r_o_n_m_e_n_t of the process.  A pointer to this array is also
     stored in the global variable ``environ''.  Each string con-
     sists of a name, an "=", and a null-terminated value.  The
     array of pointers is terminated by a null pointer.  The
     shell _s_h(1) passes an environment entry for each global
     shell variable defined when the program is called.  See
     _e_n_v_i_r_o_n(7) for some conventionally used names.

RREETTUURRNN VVAALLUUEE
     If _e_x_e_c_v_e returns to the calling process an error has
     occurred; the return value will be -1 and the global



Printed 7/27/90             November				2






EXECVE(2)		      1988			EXECVE(2)



     variable _e_r_r_n_o will contain an error code.

EERRRROORRSS
     _E_x_e_c_v_e will fail and return to the calling process if one or
     more of the following are true:

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

     [EINVAL]	    The pathname contains a character with the
		    high-order bit set.

     [ENAMETOOLONG] A component of a pathname exceeded 255 char-
		    acters, or an entire path name exceeded 1023
		    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 per-
		    mission.

     [ENOEXEC]	    The new process file has the appropriate
		    access permission, but has an invalid magic
		    number in its header.

     [ETXTBSY]	    The new process file is a pure procedure
		    (shared text) file that is currently open for
		    writing or reading by some process.

     [ENOMEM]	    The new process requires more virtual memory
		    than is allowed by the imposed maximum
		    (_g_e_t_r_l_i_m_i_t(2)).

     [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
		    <_s_y_s/_p_a_r_a_m._h>.

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

     [EFAULT]	    _P_a_t_h, _a_r_g_v, or _e_n_v_p point to an illegal
		    address.



Printed 7/27/90             November				3






EXECVE(2)		      1988			EXECVE(2)



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

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

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













































Printed 7/27/90             November				4