⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 execl.3

📁 操作系统设计与实现源码
💻 3
字号:
.\" Copyright (c) 1983 Regents of the University of California..\" All rights reserved.  The Berkeley software License Agreement.\" specifies the terms and conditions for redistribution..\".\"	@(#)execl.3	6.2 (Berkeley) 4/25/86.\".TH EXECL 3 "April 25, 1986".UC 5.SH NAMEexecl, execv, execle, execlp, execvp, exec, environ \- execute a file.SH SYNOPSIS.ft B#include <unistd.h>.in +.5i.ti -.5iint execl(const char *\fIname\fP, const char *\fIarg0\fP, ..., (char *) NULL).ti -.5iint execv(const char *\fIname\fP, char *const \fIargv\fP[]).ti -.5iint execle(const char *\fIname\fP, const char *\fIarg0\fP, ..., (char *) NULL, char *const \fIenvp\fP[]).ti -.5iint execlp(const char *\fIname\fP, const char *\fIarg0\fP, ..., (char *) NULL).ti -.5iint execvp(const char *\fIname\fP, char *const \fIargv\fP[]).in -.5iextern char *const *environ;.fi.SH DESCRIPTIONThese routines provide various interfaces to the.B execve system call.  Refer to .BR  execve (2)for a description of their properties; onlybrief descriptions are provided here..PP.B Execin all its formsoverlays the calling process with the named file, thentransfers to theentry point of the core image of the file.There can be no return from a successful exec; the callingcore image is lost..PPThe.I nameargumentis a pointer to the name of the fileto be executed.The pointers.IR arg [ 0 ],.IR arg [ 1 "] ..."address null-terminated strings.Conventionally.IR arg [ 0 ]is the name of thefile..PPTwo interfaces are available..B execlis useful when a known file with known arguments isbeing called;the arguments to.B execlare the character stringsconstituting the file and the arguments;the first argument is conventionallythe same as the file name (or its last component).A null pointer argument must end the argument list.(Note that the.B execl*functions are variable argument functions.  This means that the typeof the arguments beyond.I arg0is not checked.  So the null pointer requires an explicit cast to type.B "(char *)"if not of that type already.).PPThe.B execvversion is useful when the number of arguments is unknownin advance;the arguments to.B execvare the name of the file to beexecuted and a vector of strings containingthe arguments.The last argument string must be followedby a null pointer..PPWhen a C program is executed,it is called as follows:.PP.RS.ft B.nfint main(int \fIargc\fP, char *const \fIargv\fP[], char *const \fIenvp\fP[]);exit(main(\fIargc\fP, \fIargv\fP, \fIenvp\fP));.fi.ft R.RE.PPwhere.I argcis the argument countand.I argv is an array of character pointersto the arguments themselves.As indicated,.I argcis conventionally at least oneand the first member of the array points to astring containing the name of the file..PP.I Argvis directly usable in another.B execvbecause.IR argv [ argc ]is 0..PP.I Envpis a pointer to an array of strings that constitutethe.I environmentof the process.Each string consists of a name, an \*(lq=\*(rq, and a null-terminated value.The array of pointers is terminated by a null pointer.The shell.BR sh (1)passes an environment entry for each global shell variabledefined when the program is called.See.BR environ (7)for some conventionallyused names.The C run-time start-off routine places a copy of.I envpin the global cell.BR environ ,which is usedby.B execvand.B execlto pass the environment to any subprograms executed by thecurrent program..PP.B Execlpand.B execvpare called with the same arguments as.B execland.BR execv ,but duplicate the shell's actions in searching for an executablefile in a list of directories.The directory list is obtained from the environment variable.BR PATH .Under standard Minix, if a file is found that is executable, but doesnot have the proper executable header then it is assumed to bea shell script..B Execlpand.B execvpexecute.B /bin/shto interpret the script.Under Minix-vmd this does not happen, a script must begin with.B #!and the full path name of the interpreter if it is to be anexecutable script..SH "SEE ALSO".BR execve (2),.BR fork (2),.BR environ (7),.BR sh (1)..SH DIAGNOSTICSIf the file cannot be found,if it is not executable,if it does not start with a valid magic number (see.BR a.out (5)),if maximum memory is exceeded,or if the arguments require too much space,a returnconstitutes the diagnostic;the return value is \-1 and.B errnois set as for.BR execve .Even for the super-user,at least one of the execute-permission bits must be set fora file to be executed.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -