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

📄 execve.2

📁 Unix操作系统minix 2.0源码
💻 2
字号:
.\" Copyright (c) 1980 Regents of the University of California..\" All rights reserved.  The Berkeley software License Agreement.\" specifies the terms and conditions for redistribution..\".\"	@(#)execve.2	6.7 (Berkeley) 5/22/86.\".TH EXECVE 2 "May 22, 1986".UC 4.SH NAMEexecve \- execute a file.SH SYNOPSIS.nf.ft B#include <unistd.h>int execve(const char *\fIname\fP, char *const \fIargv\fP[], char *const \fIenvp\fP[]).ft R.fi.SH DESCRIPTION.B Execvetransforms the calling process into a new process.The new process is constructed from an ordinary filecalled the \fInew process file\fP.This file is either an executable object file,or a file of data for an interpreter.An executable object file consists of an identifying header,followed by pages of data representing the initial program (text)and initialized data pages.  Additional pages may be specifiedby the header to be initialized with zero data.  See.BR a.out (5)..PPAn interpreter file begins with a line of the form ``#! \fIinterpreter\fP''.(Minix-vmd only.)When an interpreter file is.BR execve\| 'd,the system \fBexecve\fP\|'s the specified \fIinterpreter\fP, givingit the name of the originally exec'd file as an argument andshifting over the rest of the original arguments..PPThere can be no return from a successful \fBexecve\fP because the callingcore image is lost.This is the mechanism whereby different process images become active..PPThe argument \fIargv\fP is a null-terminated array of character pointersto null-terminated character strings.  These strings constitutethe argument list to be made available to the newprocess.  By convention, at least one argument must be present inthis array, and the first element of this array should bethe name of the executed program (i.e., the last component of \fIname\fP)..PPThe argument \fIenvp\fP is also a null-terminated array of character pointersto null-terminated strings.  These strings pass information to thenew process that is not directly an argument to the command (see.BR environ (7))..PPDescriptors open in the calling process remain open inthe new process, except for those for which the close-on-execflag is set (see.BR close (2)).Descriptors that remain open are unaffected by.BR execve ..PPIgnored signals remain ignored across an.BR execve ,but signals that are caught are reset to their default values.Blocked signals remain blocked regardless of changes to the signal action.The signal stack is reset to be undefined (see.BR sigaction (2) for more information)..PPEach process has.I realuser and group IDs and an.I effectiveuser and group IDs.  The.I realID identifies the person using the system; the.I effectiveID determines his access privileges..B Execvechanges the effective user and group ID tothe owner of the executed file if the file has the \*(lqset-user-ID\*(rqor \*(lqset-group-ID\*(rq modes.  The.I realuser ID is not affected..PPThe new process also inherits the following attributes fromthe calling process:.PP.in +5n.nf.ta +2iprocess ID	see \fBgetpid\fP\|(2)parent process ID	see \fBgetppid\fP\|(2)process group ID	see \fBgetpgrp\fP\|(2)access groups	see \fBgetgroups\fP\|(2)working directory	see \fBchdir\fP\|(2)root directory	see \fBchroot\fP\|(2)control terminal	see \fBtty\fP\|(4)alarm timer	see \fBalarm\fP\|(2)file mode mask	see \fBumask\fP\|(2)signal mask	see \fBsigaction\fP\|(2), \fBsigprocmask\fP\|(2).in -5n.fi.PPWhen the executed program begins, 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 number of elements in \fIargv\fP(the ``arg count'')and.I argvis the array of character pointersto the arguments themselves..PP.I Envpis a pointer to an array of strings that constitutethe.I environmentof the process.A pointer to this array is also stored in the global variable ``environ''.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..SH "RETURN VALUEIf.B execvereturns to the calling process an error has occurred; thereturn value will be \-1 and the global variable.B errnowill contain an error code..SH ERRORS.B Execvewill fail and return to the calling process if one or moreof the following are true:.TP 15[ENOTDIR]A component of the path prefix is not a directory..TP 15[ENAMETOOLONG]The path name exceeds PATH_MAX characters..TP 15[ENOENT]The new process file does not exist..TP 15[ELOOP]Too many symbolic links were encountered in translating the pathname.(Minix-vmd).TP 15[EACCES]Search permission is denied for a component of the path prefix..TP 15[EACCES]The new process file is not an ordinary file..TP 15[EACCES]The new process file mode denies execute permission..TP 15[ENOEXEC]The new process file has the appropriate accesspermission, but has an invalid magic number in its header..TP 15[ENOMEM]The new process requires more (virtual) memory thanis currently available..TP 15[E2BIG]The number of bytes in the new process's argument listis larger than the system-imposed limit ARG_MAX.The limit in the system as released is 4096 bytes for16-bit Minix, 16384 bytes for 32-bit Minix, and unlimited for Minix-vmd..TP 15[EFAULT]\fIPath\fP\|, \fIargv\fP\|, or \fIenvp\fP pointto an illegal address..TP 15[EIO]An I/O error occurred while reading from the file system..SH CAVEATSIf a program is.I setuidto a non-super-user, but is executed whenthe real \fBuid\fP is ``root'', then the program has some of the powersof a super-user as well..SH "SEE ALSO".BR exit (2),.BR fork (2),.BR execl (3),.BR environ (7).

⌨️ 快捷键说明

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