xref: /386bsd/usr/share/man/cat3/exec.0 (revision a2142627)
1EXEC(3)                   386BSD Programmer's Manual                   EXEC(3)
2
3NNAAMMEE
4     eexxeeccll, eexxeeccllpp, eexxeeccllee, eexxeecctt, eexxeeccvv, eexxeeccvvpp - execute a file
5
6SSYYNNOOPPSSIISS
7     ##iinncclluuddee <<uunniissttdd..hh>>
8
9     _e_x_t_e_r_n _c_h_a_r **_e_n_v_i_r_o_n;
10
11     _i_n_t
12     eexxeeccll(_c_o_n_s_t _c_h_a_r *_p_a_t_h, _c_o_n_s_t _c_h_a_r *_a_r_g, ...)
13
14     _i_n_t
15     eexxeeccllpp(_c_o_n_s_t _c_h_a_r *_f_i_l_e, _c_o_n_s_t _c_h_a_r *_a_r_g, ...)
16
17     _i_n_t
18     eexxeeccllee(_c_o_n_s_t _c_h_a_r *_p_a_t_h, _c_o_n_s_t _c_h_a_r *_a_r_g, ..., _c_h_a_r *_c_o_n_s_t _e_n_v_p[])
19
20     _i_n_t
21     eexxeecctt(_c_o_n_s_t _c_h_a_r *_p_a_t_h, _c_h_a_r *_c_o_n_s_t _a_r_g_v[])
22
23     _i_n_t
24     eexxeeccvv(_c_o_n_s_t _c_h_a_r *_p_a_t_h, _c_h_a_r *_c_o_n_s_t _a_r_g_v[])
25
26     _i_n_t
27     eexxeeccvvpp(_c_o_n_s_t _c_h_a_r *_f_i_l_e, _c_h_a_r *_c_o_n_s_t _a_r_g_v[])
28
29DDEESSCCRRIIPPTTIIOONN
30     The eexxeecc family of functions replaces the current process image with a
31     new process image.  The functions described in this manual page are
32     front-ends for the function execve(2).  (See the manual page for execve
33     for detailed information about the replacement of the current process.)
34
35     The initial argument for these functions is the pathname of a file which
36     is to be executed.
37
38     The _c_o_n_s_t _c_h_a_r *_a_r_g and subsequent ellipses in the eexxeeccll(), eexxeeccllpp(), and
39     eexxeeccllee() functions can be thought of as _a_r_g_0, _a_r_g_1, ..., _a_r_g_n. Together
40     they describe a list of one or more pointers to null-terminated strings
41     that represent the argument list available to the executed program.  The
42     first argument, by convention, should point to the file name associated
43     with the file being executed.  The list of arguments _m_u_s_t be terminated
44     by a NULL pointer.
45
46     The eexxeecctt(), eexxeeccvv(), and eexxeeccvvpp() functions provide an array of pointers
47     to null-terminated strings that represent the argument list available to
48     the new program.  The first argument, by convention, should point to the
49     file name associated with the file begin executed.  The array of pointers
50     mmuusstt be terminated by a NULL pointer.
51
52     The eexxeeccllee() and eexxeecctt() functions also specify the environment of the
53     executed process by following the NULL pointer that terminates the list
54     of arguments in the parameter list or the pointer to the argv array with
55     an additional parameter.  This additional parameter is an array of
56     pointers to null-terminated strings and _m_u_s_t be terminated by a NULL
57     pointer.  The other functions take the environment for the new process
58     image from the external variable _e_n_v_i_r_o_n in the current process.
59
60     Some of these functions have special semantics.
61
62     The functions eexxeeccllpp() and eexxeeccvvpp() will duplicate the actions of the
63     shell in searching for an executable file if the specified file name does
64     not contain a slash ``/'' character.  The search path is the path
65     specified in the environment by ``PATH'' variable.  If this variable
66     isn't specified, the default path ``/bin:/usr/bin:'' is used.  In
67     addtion, certain errors are treated specially.
68
69     If permission is denied for a file (the attempted execve returned
70     EACCES), these functions will continue searching the rest of the search
71     path.  If no other file is found, however, they will return with the
72     global variable _e_r_r_n_o set to EACCES.
73
74     If the header of a file isn't recognized (the attempted execve returned
75     ENOEXEC), these functions will execute the shell with the path of the
76     file as its first argument.  (If this attempt fails, no further searching
77     is done.)
78
79     If the file is currently busy (the attempted execve returned ETXTBUSY),
80     these functions will sleep for several seconds, periodically re-
81     attempting to execute the file.
82
83     The function eexxeecctt() executes a file with the program tracing facilities
84     enabled (see ptrace(2)).
85
86RREETTUURRNN VVAALLUUEESS
87     If any of the exec functions returns, an error will have occurred.  The
88     return value is -1, and the global variable _e_r_r_n_o will be set to indicate
89     the error.
90
91FFIILLEESS
92     /bin/sh  The shell.
93
94EERRRROORRSS
95     EExxeeccll(), eexxeeccllee(), eexxeeccllpp() and eexxeeccvvpp() may fail and set _e_r_r_n_o for any
96     of the errors specified for the library functions execve(2) and
97     malloc(3).
98
99     EExxeecctt() and eexxeeccvv() may fail and set _e_r_r_n_o for any of the errors
100     specified for the library function execve(2).
101
102SSEEEE AALLSSOO
103     sh(1),  execve(2),  fork(2),  trace(2),  environ(7),  ptrace(2),
104     environ(7),
105
106CCOOMMPPAATTIIBBIILLIITTYY
107     Historically, the default path for the eexxeeccllpp() and eexxeeccvvpp() functions
108     was ``:/_b_i_n:/_u_s_r/_b_i_n''. This was changed to place the current directory
109     last to enhance system security.
110
111     The behavior of eexxeeccllpp() and eexxeeccvvpp() when errors occur while attempting
112     to execute the file is historic practice, but has not traditionally been
113     documented and is not specified by the POSIX standard.
114
115     Traditionally, the functions eexxeeccllpp() and eexxeeccvvpp() ignored all errors
116     except for the ones described above and ENOMEM and E2BIG, upon which they
117     returned.  They now return if any error other than the ones described
118     above occurs.
119
120SSTTAANNDDAARRDDSS
121     EExxeeccll(), eexxeeccvv(), eexxeeccllee(), eexxeeccllpp() and eexxeeccvvpp() conform to IEEE
122     Std1003.1-1988 (``POSIX'').
123
124BSD Experimental                April 19, 1991                               2
125
126
127
128
129
130
131
132
133