home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V6 / usr / man / man2 / exec.2 < prev    next >
Encoding:
Text File  |  1975-06-26  |  3.5 KB  |  176 lines

  1. .th EXEC II 8/5/73
  2. .sh NAME
  3. exec, execl, execv  \*-  execute a file
  4. .sh SYNOPSIS
  5. (exec = 11.)
  6. .br
  7. .ft B
  8. sys exec; name; args
  9. .br
  10. .li
  11. ...
  12. .br
  13. name: <...\\0>
  14. .br
  15. .li
  16. ...
  17. .br
  18. args: arg0; arg1; ...; 0
  19. .br
  20. arg0: <...\\0>
  21. .br
  22. arg1: <...\\0>
  23. .br
  24.    ...
  25. .s3
  26. execl(name, arg0, arg1, ..., argn, 0)
  27. .br
  28. char *name, *arg0, *arg1, ..., *argn;
  29. .s3
  30. execv(name, argv)
  31. .br
  32. char *name;
  33. .br
  34. char *argv[ ];
  35. .ft R
  36. .sh DESCRIPTION
  37. .it Exec
  38. overlays the calling process with the named file, then
  39. transfers to the
  40. beginning of the core image of the file.
  41. There can be no return from the file; the calling
  42. core image is lost.
  43. .s3
  44. Files remain open across
  45. .it exec
  46. calls.
  47. Ignored signals remain ignored across
  48. .it exec,
  49. but
  50. signals that are caught are reset
  51. to their default values.
  52. .s3
  53. Each user has a
  54. .it real
  55. user ID and group ID and an
  56. .it effective
  57. user ID and group ID.
  58. The
  59. real
  60. ID
  61. identifies the person using the system;
  62. the
  63. effective
  64. ID
  65. determines his access privileges.
  66. .it Exec
  67. changes the effective user and group ID to
  68. the owner of the executed file if the file has the ``set-user-ID''
  69. or ``set-group-ID''
  70. modes.
  71. The
  72. real
  73. user ID is not affected.
  74. .s3
  75. The form of this call differs somewhat depending
  76. on whether it is called from assembly language or C;
  77. see below for the C version.
  78. .s3
  79. The first argument to
  80. .it exec
  81. is a pointer to the name of the file
  82. to be executed.
  83. The second is the address of a null-terminated list of pointers to
  84. arguments to be passed to the file.
  85. Conventionally, the first argument is the name of the
  86. file.
  87. Each pointer addresses a string terminated by a null byte.
  88. .s3
  89. Once the called file starts execution, the arguments are available
  90. as follows.
  91. The stack pointer points to a word containing the number of arguments.
  92. Just above
  93. this number is a list of pointers to the argument strings.
  94. The arguments are placed as high as possible in core.
  95. .s3
  96.   sp\*>    nargs
  97. .br
  98.     arg0
  99. .br
  100.     ...
  101. .br
  102.     argn
  103. .br
  104.     \*-1
  105. .s3
  106.  arg0:    <arg0\\0>
  107. .br
  108.     ...
  109. .br
  110.  argn:    <argn\\0>
  111. .s3
  112. From C, two interfaces are available.
  113. .it execl
  114. is useful when a known file with known arguments is
  115. being called;
  116. the arguments to
  117. .it execl
  118. are the character strings
  119. constituting the file and the arguments; as in
  120. the basic call, the first argument is conventionally
  121. the same as the file name (or its last component).
  122. A 0 argument must end the argument list.
  123. .s3
  124. The
  125. .it execv
  126. version is useful when the number of arguments is unknown
  127. in advance;
  128. the arguments to
  129. .it execv
  130. are the name of the file to be
  131. executed and a vector of strings containing
  132. the arguments.
  133. The last argument string must be followed
  134. by a 0 pointer.
  135. .s3
  136. When a C program is executed,
  137. it is called as follows:
  138. .s3
  139.     main(argc, argv)
  140. .br
  141.     int argc;
  142. .br
  143.     char **argv;
  144. .s3
  145. where \fIargc\fR is the argument count
  146. and \fIargv\fR is an array of character pointers
  147. to the arguments themselves.
  148. As indicated, \fIargc\fR is conventionally at least one
  149. and the first member of the array points to a
  150. string containing the name of the file.
  151. .s3
  152. .it Argv
  153. is not directly usable in another
  154. .it execv,
  155. since
  156. .it argv[argc]
  157. is \*-1 and not 0.
  158. .sh "SEE ALSO"
  159. fork (II)
  160. .sh DIAGNOSTICS
  161. If the file cannot be found,
  162. if it is not executable,
  163. if it does not have a valid header (407, 410, or 411 octal as first word),
  164. if maximum memory is exceeded,
  165. or if the arguments require more than 512 bytes
  166. a return from
  167. .it exec
  168. constitutes the diagnostic;
  169. the error bit (c-bit) is set.
  170. Even for the super-user,
  171. at least one of the execute-permission bits must be set for
  172. a file to be executed.
  173. From C the returned value is \*-1.
  174. .sh BUGS
  175. Only 512 characters of arguments are allowed.
  176.