|
|
1.1 ! root 1: .th EXEC II 8/5/73 ! 2: .sh NAME ! 3: exec \*- 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: arg1; arg2; ...; 0 ! 19: .br ! 20: arg1: <...\\0> ! 21: .br ! 22: arg2: <...\\0> ! 23: .br ! 24: ... ! 25: .s3 ! 26: execl(name, arg1, arg2, ..., argn, 0) ! 27: .br ! 28: char *name, *arg1, *arg2, ..., *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: arg1 ! 99: .br ! 100: ... ! 101: .br ! 102: argn ! 103: .s3 ! 104: arg1: <arg1\\0> ! 105: .br ! 106: ... ! 107: .br ! 108: argn: <argn\\0> ! 109: .s3 ! 110: From C, two intefaces are available. ! 111: .it execl ! 112: is useful when a known file with known arguments is ! 113: being called; ! 114: the arguments to ! 115: .it execl ! 116: are the character strings ! 117: constituting the file and the arguments; as in ! 118: the basic call, the first argument is conventionally ! 119: the same as the file name (or its last component). ! 120: A 0 argument must end the argument list. ! 121: .s3 ! 122: The ! 123: .it execv ! 124: version is useful when the number of arguments is unknown ! 125: in advance; ! 126: the arguments to ! 127: .it execv ! 128: are the name of the file to be ! 129: executed and a vector of strings containing ! 130: the arguments. ! 131: The last argument string must be followed ! 132: by a 0 pointer. ! 133: .s3 ! 134: When a C program is executed, ! 135: it is called as follows: ! 136: .s3 ! 137: main(argc, argv) ! 138: .br ! 139: int argc; ! 140: .br ! 141: char *argv[]; ! 142: .s3 ! 143: where \fIargc\fR is the argument count ! 144: and \fIargv\fR is an array of character pointers ! 145: to the arguments themselves. ! 146: As indicated, \fIargc\fR is conventionally at least one ! 147: and the first member of the array points to a ! 148: string containing the name of the file. ! 149: .s3 ! 150: .it Argv ! 151: is not directly usable in another ! 152: .it execv, ! 153: since ! 154: .it argv[argc] ! 155: is \*-1 and not 0. ! 156: .sh "SEE ALSO" ! 157: fork(II) ! 158: .sh DIAGNOSTICS ! 159: If the file cannot be found, ! 160: if it is not executable, ! 161: if it does not have a valid header (407 or 410 octal as first word), ! 162: if maximum memory is exceeded, ! 163: or if the arguments require more than 512 bytes ! 164: a return from ! 165: .it exec ! 166: constitutes the diagnostic; ! 167: the error bit (c-bit) is set. ! 168: From C the returned value is \*-1. ! 169: .sh BUGS ! 170: Only 512 characters of arguments are allowed.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.