Server for Information Technologies

(095) 932-9212, 932-9213, 939-0783
E-mail: info@citforum.ru
(!) CIT Forum CD-ROM

EXEC(3)
XENIX System V (21 1987)


execl, execv, execle, execve, execlp, execvp - oee aa

	int execl (path, arg0, arg1, ..., argn, (char*)0)
	char *path, *arg0, *arg1, ..., *argn;
	
	int execv (path, argv)
	char *path, *argv[];
	
	int execle (path, arg0, arg1, ..., argn, (char*)0, envp)
	char *path, *arg0, *arg1,..., *argn, *envp[];
	
	int execve (path, argv, envp)
	char *path, *argv[], *envp[];
	
	int execlp (file, arg0, arg1, ..., argn, (char*)0)
	char *file, *arg0, *arg1,..., *argn;
	
	int execvp (file, argv)
	char *file, *argv[];


y ceeca exec ae ey opa poecca o opao. Ho opa eaec oeoo aa, aaeoo ao opaa poecca. oce yceoo oe oa exec eooe opa cap opa poecca, ocoy o epep o opao.

Apye path aae aa, coepaeo o opa poecca.

Apye file ae aae aa, coepaeo o opa poecca. Ec apye file e coep co /, pec e oo aa oyaec oceoaeo ocaoo e aaoo, yaax ae epeeo PATH (c. environ(7)). Koaa cpea oppyec eppeaopo oa (c. sh(1)).

Apye arg0, arg1, ..., argn c yaae a cpo coo, aepaee coo NUL. Cpo peca coo cco apyeo, epeaaex ooy opay poecca. Apye arg0 oe pcycoa cea oe yaa a cpoy, o coaay c path, o coepay oce ooe path.

Apye argv ec acco yaaee a coe cpo, aepaee coo NUL. Cpo peca coo cco apyeo, epeaaex ooy opay poecca. Apye argv[0] oe pcycoa cea oe yaa a cpoy, o coaay c path, o coepay oce ooe path.

Apye envp ec acco yaaee a coe cpo, aepaee coo NUL. Cpo peca coo oay cpey ooo opaa poecca. oce ee acca oe ye yaaee.

a, ope cap (a) opao poecca, ocac op oo opae a cee ex, y oopx a ap p exec pae 1; (c. fcntl(3)). aae o ex aax, o ocac op, e eec.

Ca, a oope capo opae poecca a ycaoea caapa pea (SIG_DFL) oppoae (SIG_IGN), ocac a e oo opae. Ha ca, oope capo opae oe epexaae, oo opae ycaaaec caapa pea cce (c. signal(3)).

Ec ycao ooaecoo ID y aa opaa poecca pae 1 (c. chmod(2)), e ooaec ID poecca c o opao oaaec pa ooaecoy ID aa. Aaoo, ec ycao pyooo ID y aa opaa poecca pae 1, e pyoo ID poecca c o opao oaaec pa pyooy ID aa. Peae ooaec pyoo IDs poecca ocac ee.

popoae oce exec apeeo (c. profil(2)).

Ho opa poecca aceye o capoo opaa o pae epe, ceye apy:

     ooaecy oay  popey poecca (c. nice(2))
     ID poecca
     ID poecca-oa
     ID py poecco
     ae ceaopo (c. semop(2))
     ID epao py (c. exit(2)  signal(3))
     a paccpo (c. ptrace(2), apoc 0)
     aep poecca (c. alarm(2))
     ey aao
     opeo aao
     acy oa a (c. umask(2))
     aca paep aa (c. ulimit(2))
     tms_utime, tms_stime, tms_cutime, tms_cstime (c.
     times(2)).

B popaax a e C peaa oa exec oo ooac y execl execv. y execl peec oa, oa oeoo aa epeaaee apye ec apaee; o yaac e cox cpo - apyeo y. o coae, ep apye oe coaa o c ee aa, o c oce ooeo oo e. oce apyeo cce oe yeo yaae.

y execv peec, oa apaee eeco co apyeo. Apyea o cyae c aa acc cpo, coepax epeaaee ay apye. oce eeo acca oe yeo yaae.

popaa a e C, oyaa ypaee peyae exec, oa e cey opao oca xo:

     void main (argc, argv, envp)
     int argc;
     char **argv, **envp;
e argc - ce ca apyeo;
argv - acc yaaee a apye, pecaee e cox cpo;
envp - acc yaaee cpo, peca coo oay cpey.

argc oe , o pae epe, e ee 1 argv[0] oe coaa c ee oce ooeo e aa.

argv oe eocpeceo cooac pyo execv, ocoy argv[argc] pae 0.

Kaa cpoa acce, yaaeo envp, coco e, aa "=" ae (coo cpo, aepaeo coo NUL). Macc aepaec ye yaaee. eppeaop oa sh(1) epeae aeo popae aece oao cpe ea ae oax epeex, oex coppye. Cco oo coppyex e c. environ(7). p oe popa aee envp pcaaec ee epeeo environ, oopa coyec execv execl epea oao cpe o opopae ao popa. epecee e y opao epea oay cpey:

	execle (file, arg0, arg1, ..., argn, 0, environ);
	execve (file, argv, environ);

execlp execvp ac c e e apyea, o execl execv, o y aa, pocapa aao a e, a sh(1). Cco aaoo epec oao cpe.

exec aapo aepaec opaae ypaee cap opa poecca, ec oec xo oo ceyx yco:
[ENOENT] Kooe e aa opaa poecca e cyecye.
[ENOTDIR] Kooe peca e aa opaa poecca e ec aaoo.
[EACCES] o e papee a oc aaoe peca e aa opaa poecca.
[EACCES] a opaa poecca e ec o.
[EACCES] He papee a oee aa opaa poecca.
[ENOEXEC] a opaa poecca ee papeee a oee, o eo opa e coaae c opao oeoo aa.
[ETXTBSY] Ho a opaa poecca ec co poeypo (paee ceeo cpy), oop a oe op a ac py poecco.
[ENOMEM] Ho opa poecca peye a oe, e ey oe eeo oepao a oac coa.
[E2BIG] co ao cce apye, epeaaex ooy opay, peae peycope cceo 512 ao.
[EFAULT] a ooo aa opaa e coaae c yaao aooe.
[EFAULT] Apec, aa path, argv envp, xo a pee ooaecoo apecoo pocpaca poecca.

BOPAAEOE AEE
B cyae yceoo aepe e pocxo opaa ypae ae cap opa poecca. ae ypaee opaaec cap opa, opaaec aee -1 errno aocc o o.

.
exit(3), fork(3), proctl(3), semop(3)


exec oe aapo aepc, ec oe oepao a peae paep oac coa (c. e o o ENOMEM). Oao, o opaee caec cooae ceyx apao oa proctl(3):
PRHUGEX ooe o popay ae, ec ee paep peae paep oac coa. Tae popa o oeac ocyy ac oepao a e ooaec ID poecca oe pepoa. poecc, o popay aoo paepa, opyec cceo o py oac coa.
PRNORMX apeae poeccy o popay oooo paepa. o o oe cea o poecc.
Comments: info@citmgu.ru
Designed by Andrey Novikov
Copyright © CIT