📄 exec.2
字号:
.th EXEC II 8/5/73.sh NAMEexec, execl, execv \*- execute a file.sh SYNOPSIS(exec = 11.).br.ft Bsys exec; name; args.br.li....brname: <...\\0>.br.li....brargs: arg0; arg1; ...; 0.brarg0: <...\\0>.brarg1: <...\\0>.br ....s3execl(name, arg0, arg1, ..., argn, 0).brchar *name, *arg0, *arg1, ..., *argn;.s3execv(name, argv).brchar *name;.brchar *argv[ ];.ft R.sh DESCRIPTION.it Execoverlays the calling process with the named file, thentransfers to thebeginning of the core image of the file.There can be no return from the file; the callingcore image is lost..s3Files remain open across.it execcalls.Ignored signals remain ignored across.it exec,butsignals that are caught are resetto their default values..s3Each user has a.it realuser ID and group ID and an.it effectiveuser ID and group ID.TherealIDidentifies the person using the system;theeffectiveIDdetermines his access privileges..it Execchanges the effective user and group ID tothe owner of the executed file if the file has the ``set-user-ID''or ``set-group-ID''modes.Therealuser ID is not affected..s3The form of this call differs somewhat dependingon whether it is called from assembly language or C;see below for the C version..s3The first argument to.it execis a pointer to the name of the fileto be executed.The second is the address of a null-terminated list of pointers toarguments to be passed to the file.Conventionally, the first argument is the name of thefile.Each pointer addresses a string terminated by a null byte..s3Once the called file starts execution, the arguments are availableas follows.The stack pointer points to a word containing the number of arguments.Just abovethis number is a list of pointers to the argument strings.The arguments are placed as high as possible in core..s3 sp\*> nargs.br arg0.br ....br argn.br \*-1.s3 arg0: <arg0\\0>.br ....br argn: <argn\\0>.s3From C, two interfaces are available..it execlis useful when a known file with known arguments isbeing called;the arguments to.it execlare the character stringsconstituting the file and the arguments; as inthe basic call, the first argument is conventionallythe same as the file name (or its last component).A 0 argument must end the argument list..s3The.it execvversion is useful when the number of arguments is unknownin advance;the arguments to.it execvare the name of the file to beexecuted and a vector of strings containingthe arguments.The last argument string must be followedby a 0 pointer..s3When a C program is executed,it is called as follows:.s3 main(argc, argv).br int argc;.br char **argv;.s3where \fIargc\fR is the argument countand \fIargv\fR is an array of character pointersto the arguments themselves.As indicated, \fIargc\fR is conventionally at least oneand the first member of the array points to astring containing the name of the file..s3.it Argvis not directly usable in another.it execv,since.it argv[argc]is \*-1 and not 0..sh "SEE ALSO"fork (II).sh DIAGNOSTICSIf the file cannot be found,if it is not executable,if it does not have a valid header (407, 410, or 411 octal as first word),if maximum memory is exceeded,or if the arguments require more than 512 bytesa return from.it execconstitutes the diagnostic;the error bit (c-bit) is set.Even for the super-user,at least one of the execute-permission bits must be set fora file to be executed.From C the returned value is \*-1..sh BUGSOnly 512 characters of arguments are allowed.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -