File: execve.2

package info (click to toggle)
manpages-ja 0.5.0.0.20080615-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 20,508 kB
  • ctags: 1
  • sloc: sh: 13,690; perl: 157; makefile: 114
file content (625 lines) | stat: -rw-r--r-- 17,432 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
.\" Hey Emacs! This file is -*- nroff -*- source.
.\" and Copyright (c) 2006 Michael Kerrisk <mtk.manpages@gmail.com>
.\"
.\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.  The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Modified by Michael Haardt <michael@moria.de>
.\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu>
.\" Modified 1994-08-21 by Michael Chastain <mec@shell.portal.com>:
.\" Modified 1997-01-31 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified 1999-11-12 by Urs Thuermann <urs@isnogud.escape.de>
.\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
.\" 2006-09-04 Michael Kerrisk <mtk.manpages@gmail.com>
.\"     Added list of process attributes that are not preserved on exec().
.\" 2007-09-14 Ollie Wild <aaw@google.com>, mtk
.\"     Add text describing limits on command-line arguments + environment
.\"
.\" Japanese Version Copyright (c) 1996 TABATA Tomohira
.\"         all rights reserved.
.\" Translated 1996-07-04, TABATA Tomohira <loba@k2.t.u-tokyo.ac.jp>
.\" Updated 1997-12-14, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated 2001-08-17, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated 2005-02-05, Yuichi SATO <ysato444@yahoo.co.jp>
.\" Updated 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated 2005-11-19, Akihiro MOTOKI
.\" Updated 2006-08-13, Akihiro MOTOKI, LDP v2.39
.\" Updated 2007-01-09, Akihiro MOTOKI, LDP v2.43
.\" Updated 2007-06-03, Akihiro MOTOKI, LDP v2.51
.\" Updated 2007-10-12, Akihiro MOTOKI, LDP v2.66
.\"
.TH EXECVE 2 2007-09-14 "Linux" "Linux Programmer's Manual"
.SH ̾
execve \- ץ¹Ԥ
.SH 
.B #include <unistd.h>
.sp
.BI "int execve(const char *" filename ", char *const " argv "[], "
.br
.BI "           char *const " envp []);
.SH 
.BR execve ()
ϡ\fIfilename\fP ˤäƻꤵ줿ץ¹Ԥ롣
\fIfilename\fP ϡХʥ¹Է
ʲηιԤǻϤޤ륹ץȤǤʤФʤʤ

.in +4n
.nf
\fB#!\fP \fIinterpreter \fP[optional-arg]
.fi
.in

Ԥξܺ٤ϡΡ֥󥿥ץ꥿ץȡפ򻲾ȤΤȡ

\fIargv\fP ϿץϤʸǤ롣
\fIenvp\fP ʸǤꡢŪ \fBkey=value\fP η
ƤꡢץδĶѿȤϤ롣
\fIargv\fP  \fIenvp\fP Ϥ NULL ݥ󥿤ǽäƤ
ɬפ롣ȴĶѿϡƤӽФ줿ץ main ؿ
ʲΤ褦뤳Ȥˤäƥǽˤʤ롣

.in +4n
.nf
int main(int argc, char *argv[], char *envp[])
.fi
.in

.BR execve ()
֤ʤ
ơƤӽФΥץ text, data, bss, åϡ
ɤ߹ޤ줿ץˤäƾ񤭤롣

Υץब ptrace Ƥ硢
.BR execve ()

Υץ \fBSIGTRAP\fP 롣

.I filename
ǻꤵ줿ץե set-user-ID ӥåȤꤵƤꡢ
ե뤬¸ߤե륷ƥब
.I nosuid
.RB ( mount (2)

.B MS_NOSUID
ե饰) ǥޥȤƤ餺
ƤӽФץ ptrace Ƥʤ硢
ƤӽФץμ¸ (effective) 桼 ID 
ץեνͭ (owner) ѹ롣
Ʊͤˡץե set-group-ID ӥåȤꤵƤ硢
ƤӽФץͭ롼 ID 
ץեΥ롼פѹ롣

ץμ¸桼 ID ¸ (saved) set-user-ID ˥ԡ롣
Ʊͤˡ¸롼 ID ¸ set-group-ID ˥ԡ롣
Υԡϡset-user-ID / set-group-ID ĥӥåȤˤȯ
¸ ID ѹ˹Ԥ롣

¹ԥե뤬ưŪ󥯤줿 a.out ¹Էǡͭ饤֥
֤ޤΤä硢¹Ԥγϻ Linux 
ʥߥå
.BR ld.so (8)
ƤӽФ졢ɬפʶͭ饤֥ɤ߹ǥ󥯤Ԥ

¹ԥե뤬ʥߥå󥯤줿 ELF ¹Էä硢
PT_INTERP Ȥ˻ꤵ줿󥿥ץ꥿ɬפ
ͭ饤֥ (shared library) ɤ߹Τ˻Ѥ롣
̾󥿥ץ꥿ȤƤϡ
Linux libc 5 󥯤Хʥξˤ
\fI/lib/ld-linux.so.1\fP 
glibc 2 󥯤Хʥξˤ
\fI/lib/ld-linux.so.2\fP Ѥ롣

ʲ˼ʳΤ٤ƤΥץ°
.BR execve ()
ݻ롣
.IP * 3
Ԥ (pending) Υʥ뽸ϥꥢ
.RB ( sigpending (2))
.IP *
ª줿ʥνˡ (disposition) ϡ̵פ˥ꥻåȤ롣
.IP *
إʥ륹åϤɤݻʤ
.RB ( sigaltstack (2))
.IP *
ޥåԥ󥰤ݻʤ
.RB ( mmap (2))
.IP *
ղä줿 (attached) System V ͭꥻȤʬΥ
.RB ( shmat (2))
.IP *
POSIX ͭΰϥޥåԥ󥰤
.RB ( shm_open (3))
.IP *
ץ󤵤줿 POSIX å塼ǥץϥ
.RB ( mq_overview (7))
.IP *
ץ󤵤줿 POSIX ̾դޥեϤ⥯
.RB ( sem_overview (7))
.IP *
POSIX ޤݻʤ
.RB ( timer_create (3))
.IP *
ץ󤵤줿ǥ쥯ȥꥹȥ꡼Ϥ⥯
.RB ( opendir (3))
.IP *
åݻʤ
.RB ( mlock (2),
.BR mlockall (2))
.IP *
λ (exit) ϥɥݻʤ
.RB ( atexit (3),
.BR on_exit (3))
.PP
嵭ΥꥹȤΥץ°Ϥ POSIX.1-2001 ǵꤵƤ롣
ʲ˼ Linux ͭΥץ°
.BR execve ()
ݻʤ
.IP * 3
set-user-ID  set-group-ID 줿ץब¹ԤƤ硢
.BR prctl (2)

.B PR_SET_DUMPABLE
ե饰ϥꥢ롣ʳξ硢Υե饰ϥåȤ롣
.IP *
.BR prctl (2)

.B PR_SET_KEEPCAPS
ե饰ϥꥢ롣
.IP *
ץ̾Ͽ¹ԥե̾˥ꥻåȤ롣
ץ̾
.BR prctl (2)

.B PR_SET_NAME
Ǥ
.I "ps \-o comm"
ɽǤ롣
.IP *
λʥ (termination signal) 
.B SIGCHLD
˥ꥻåȤ
.RB ( clone (2)
)
.PP
ʲˤĤƤդ뤳:
.IP * 3
ƤӽФåɰʳƤΥåɤ
.BR execve ()
˴롣
mutexѿ¾ pthread ֥Ȥݻʤ
.IP *
\fIsetlocale(LC_ALL, "C")\fP νץ೫ϻ˼¹Ԥ롣
.IP *
POSIX.1-2001 ϡư̵뤫ǥեȤꤵƤƤΥʥ
νˡѹΤޤޤˤ롢ȵꤷƤ롣
âPOSIX.1-2001 ˤϰ㳰ꡢ
.B SIGCHLD
̵ˤʤäƤ硢
νˡѹˤΤޤޤˤ뤫ǥեư˥ꥻåȤ뤫
¸ȤʤäƤ롣
Linux Ǥ (ѹʤ) ȤʤäƤ롣
.IP *
λƤʤƱ I/O ϥ󥻥뤵
.RB ( aio_read (3),
.BR aio_write (3))
.IP *
.BR execve (2)
ΥѥӥƥΰˤĤƤϡ
.BR capabilities (7)
򻲾ȡ
.IP *
ǥեȤǤϡեǥץ
.BR execve ()
ԤäǤ⥪ץ󤵤줿ޤޤǤ롣
close-on-exec ΰդƤեǥץϥ롣
.BR fcntl (2)

.B FD_CLOEXEC
򻲾ȡ
(եǥץȡΥץ
եǥץбեФƳƤ
쥳ɤΥåƲ뤳Ȥˤʤ롣)
POSIX.1-2001 Ǥϡ
եǥץ 0, 1, 2 
.BR execve ()
ˤɤǥ졢
¹Ԥե set-user_ID  set-group_ID εĥӥåȤ
åȤƤƥץø硢
ƥϲ餫Υե򥪡ץ󤹤ݤ
ֹΥǥץΤɤ줫ȤȤ롢
ȤƤ롣
§ȤơܿɬפʥץǤϡ
ø̵ͭ˴ؤ餺
.BR execve ()
Ǥ 3ĤΥեǥץ줿ޤޤ
뤳Ȥˤ뤳ȤϤǤʤ
.\" On Linux it appears that these file descriptors are
.\" always open after an execve(), and it looks like
.\" Solaris 8 and FreeBSD 6.1 are the same. -- mtk, 30 Apr 2007
.SS 󥿥ץ꥿ץ
󥿥ץ꥿ץȤȤϡ¹ԵĤͭˤʤäƤơ
ǽιԤʲηˤʤäƤƥȥեΤȤǤ롣

.in +4n
.nf
\fB#!\fP \fIinterpreter \fP[optional-arg]
.fi
.in

.I interpreter
ͭʼ¹ԥեΥѥ̾ǤʤФʤ餺
켫ȤץȤǤäƤϤʤʤ
.BR execve ()

.I filename
󥿥ץ꥿ץȤꤷƤ硢
.I interpreter
ϰʲΰǵư롣

.in +4n
.nf
\fIinterpreter\fP [optional-arg] \fIfilename\fP arg...
.fi
.in

.I arg...

.BR execve ()

.I argv
ؤǤ롣

ܿˤϡ
.I optional-arg
϶ 1ɤˤ٤Ǥ
(Ĥޤꡢۥ磻ȡڡޤ٤ǤϤʤ)
Ρաפ򻲾ȡ
.SS "ȴĶѿιץξ"
ۤȤɤ Unix μϡץϤȤǤ
ޥɥ饤
.RI ( argv )
ȴĶѿ
.RI ( envp )
ʸ󷲤ιץ˲餫ξ¤ߤƤ롣
POSIX.1 ϡ
.B ARG_MAX
ȤäƤξ¤ǧƤ
.RB ( ARG_MAX

.I <limits.h>
뤫¹Ի
.I "sysconf(_SC_ARG_MAX)"
θƤӽФǤ뤫Τ줫Ǥ)

ͥ 2.6.23  Linux ǤϡĶѿȰʸ󷲤
ǼΤ˻Ѥ 32 ڡ¤Ƥ
(32 ڡȤΤϥͥ
.B MAX_ARG_PAGES
)äơ
ڡ 4 kB ΥƥǤϡ
祵 128 kB ȤȤˤʤ롣

ͥ 2.6.23 ʹߤǤϡۤȤɤΥƥ
꥽ΥեȾ
.B RLIMIT_STACK
˴Ť¤Ȥ롣
ΥƥǤϡץξ¤ϵĤ줿å
1/4ʸξ¤ 32 ڡ (ͥ
.BR MAX_ARG_STRLEN )
ǡʸκͤ 0x7FFFFFFF Ǥ롣
(ѹˤꡢץϤޤǤ礭ʰĶѿ
ꥹȤˤʤ롣
ץ˥å 1/4 ξ¤ߤƤΤϡ
ץबɬ٤Υå֤Ƥ뤳Ȥݾڤ
Ǥ롣)
˥å (MMU) ʤƥϾ嵭ѹ
㳰Ǥ롣ΥƥǤϥͥ 2.6.23 
Ʊ¤Τޤ޻Ѥ롣
.\" Ollie: That doesn't include the lists of pointers, though,
.\" so the actual usage is a bit higher (1 pointer per argument).
.SH ֤

.BR execve ()
֤ʤ顼ξ \-1 ֤
.I errno
Ŭڤꤹ롣
.SH 顼
.TP
.B E2BIG
Ķѿ
.RI ( envp )
Ȱꥹ
.RI ( argv )
ιץХȿ礭᤮롣
.TP
.B EACCES
.I filename
䥹ץȥ󥿥ץ꥿̾ιǤ˸ (search permission)
ͿƤʤ
.RB ( path_resolution (7)
⻲Ȥ뤳)
.TP
.B EACCES
ե⤷ϥץȤΥ󥿥ץ꥿̾ե (regular file)
Ǥʤ
.TP
.B EACCES
ե䥹ץȤ ELF 󥿥ץ꥿
¹Ե (execute permission) ͿƤʤ
.TP
.B EACCES
ե롦ƥब
.I noexec
ǥޥȤƤ롣
.TP
.B EFAULT
.I filename
ǽʥɥ쥹֤γؤƤ롣
.TP
.B EINVAL
ELF ¹Էʣ PT_INTERP Ȥ¸ߤ롣
(ʤʣΥ󥿥ץ꥿ꤷ)
.TP
.B EIO
I/O 顼ȯ
.TP
.B EISDIR
ELF 󥿥ץ꥿ǥ쥯ȥä
.TP
.B ELIBBAD
ELF 󥿥ץ꥿ǤեޥåȤǤʤä
.TP
.B ELOOP
.I filename
䥹ץȤ ELF Υ󥿥ץ꥿褹ݤ
ܥå󥯤¿᤮롣
.TP
.B EMFILE
ΥץץǤեξ¤ޤǴ˥ץ󤷤Ƥ롣
.TP
.B ENAMETOOLONG
.I filename
Ĺ᤮롣
.TP
.B ENFILE
ΥƥǥץǤե¤ã
.TP
.B ENOENT
ե
.I filename
ץȤ ELF Υ󥿥ץ꥿¸ߤʤ
.TP
.B ENOEXEC
¹ԥե뤬ǤʤǤ뤫㤦ƥΤΤ
¾Υեޥåȡ顼ˤ¹ԤǤʤä
.TP
.B ENOMEM
ͥ˽ʬʥ꤬ʤ
.TP
.B ENOTDIR
.I filename
䥹ץȤ ELF Υ󥿥ץ꥿ιǤǥ쥯ȥǤʤ
.TP
.B EPERM
ե롦ƥब
.I nosuid
ǥޥȤ졢桼ѡ桼Ǥʤ
ե set-user-ID 뤤 set-group-ID ӥåȤꤵƤ롣
.TP
.B EPERM
ץȥ졼졢桼ѡ桼Ǥʤ
ե set-user-ID 뤤 set-group-ID ӥåȤꤵƤ롣
.TP
.B ETXTBSY
¹ԥե񤭹Ѥ˥ץ󤷤Ƥץ롣
.SH 
SVr4, 4.3BSD, POSIX.1-2001.
POSIX.1-2001 ˤ #! ưˤĤƤεҤϤʤ
¾ϸߴ롣
.\" SVr4 ˤ¾ EAGAIN, EINTR, ELIBACC, ENOLINK, EMULTIHOP
.\" ˤĤƤεҤ롣
.\" POSIX ˤ ETXTBSY, EPERM, EFAULT, ELOOP, EIO, ENFILE, EMFILE,
.\" EINVAL, EISDIR, ELIBBAD 顼֤ˤĤƤεҤϤʤ
.SH 
set-user-id ץ set-group-ID ץ
.BR ptrace (2)
Ǥʤ

Linux ϥץȤ set-user-ID  set-group-ID ӥåȤ̵뤹롣

ե륷ƥ
.I nosuid
ǥޥȤ set-user-ID/set-group-ID μ¹ԥե
ɤͤ˰ϡLinux ͥΥСˤäưۤʤ:
СǤϡǤɬפʸ¤äƤơ
μ¹Ԥݤ (
.B EPERM
֤)̤ΤСǤ
set-user-ID/set-group-ID ӥåȤΤߤ̵뤷
.BR exec ()

#! ¹ԷΥ롦ץȤ 1ܤ˵Ƥʸϡ
 127 ʸǤ롣

󥿥ץ꥿ץȤ
.I optional-arg
βˡϼˤۤʤ롣
Linux Ǥϡ󥿥ץ꥿̾
.I interpreter
³ʸΤ󥿥ץ꥿ 1ĤΰȤϤ롣
ưۤʤ륷ƥ⤢롣
륷ƥǤϡ
.\" 㤨СSolaris 8
.I optional-arg
ΤǽΥۥ磻ȡڡޤǤ
ȤϤ롣
ޤ̤ΥƥǤ
.\" 㤨С6.0  FreeBSD (FreeBSD 6.0 ʹߤϰ㤦)
󥿥ץ꥿ץȤʣΰĤȤǤ
.I optional-arg
Υۥ磻ȡڡζڤȤʤ롣

Linux Ǥϡ
.I argv

.I envp
 NULL ꤹ뤳ȤǤ롣ϡΰ NULL ݥ
1ĤޤꥹȤؤΥݥ󥿤ꤷΤƱ̤ġ
.BR ֤δְäǽѤʤȡ 
ɸǡܿʤ
¾ΤۤȤɤ Unix ƥǤϡԤȥ顼ˤʤ롣
.\" e.g., EFAULT on Solaris 8 and FreeBSD 6.1; but
.\" HP-UX 11 is like Linux -- mtk, Apr 2007
.\" FIXME .
.\" Bug filed 30 Apr 2007: http://bugzilla.kernel.org/show_bug.cgi?id=8408
.\" Maybe this will get fixed (but it would constitute an ABI change).
.\"
.\" .SH Х
.\" Linux ǤˤϡELF 󥿥ץ꥿ˤ
.\" ¤Υå˼ԤΤ롣
.\" ϥƥۡǤ롣
.\" ʤʤ顢桼ǤդΥե򥪡ץĤꡢ
.\" ɤ߹ߤΤ˥ơץǥХ򴬤ᤷĤꤹ롣
.\" Linux Ǥˤ
.\" .BR execve ()
.\" ¾Υƥۡ뤬
.\" ¸ߤΤ⤢ꡢ̯˺ٹ줿 ELF Хʥˤä
.\" ӥ (denial of service) ѤƤޤ
.\" 2.0.34 ޤ 2.2.15 ˤϡΤƤϤʤ
.SS 
Unix V6 Ǥ
.BR exec ()
ΰꥹȤ 0 ǽü졢
.I main
ΰꥹȤ \-1 ǽüƤ
Τᡢ
.I main
ΰꥹȤϡθ
.BR exec ()
ˤľܻѤǤʤä
Unix V7 ʹߤǤϡȤ NULL ǽü롣
.SH 
ΥץϡʲܤΥץफ¹Ԥ뤿ΤΤǤ롣
ޥɥ饤 1Ԥ 1ĤɽΥץǤ롣

.in +4n
.nf
/* myecho.c */

#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char *argv[])
{
    int j;

    for (j = 0; j < argc; j++)
        printf("argv[%d]: %s\\n", j, argv[j]);

    exit(EXIT_SUCCESS);
}
.fi
.in

ʲΥץϡޥɥ饤ǻꤷ̾Υץ
¹ԤΤ˻Ȥ

.in +4n
.nf
/* execve.c */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>

int
main(int argc, char *argv[])
{
    char *newargv[] = { NULL, "hello", "world", NULL };
    char *newenviron[] = { NULL };

    assert(argc == 2);  /* argv[1] identifies
                           program to exec */
    newargv[0] = argv[1];

    execve(argv[1], newargv, newenviron);
    perror("execve");   /* execve() only returns on error */
    exit(EXIT_FAILURE);
}
.fi
.in

ܤΥץȤäưܤΥץ¹Ԥˤ
ʲΤ褦ˤ롣

.in +4n
.nf
$ cc myecho.c -o myecho
$ cc execve.c -o execve
$ ./execve ./myecho
argv[0]: ./myecho
argv[1]: hello
argv[2]: world
.fi
.in

ˡΥץȤäơץȡ󥿥ץ꥿򼨤
Τˡ֥󥿥ץ꥿פȤۤɺץ
.I myecho
ȤץȤ롣

.in +4n
.nf
$ cat > script.sh
#! ./myecho script-arg
^D
$ chmod +x script.sh
.fi
.in

ƤץȤäƥץȤ¹Ԥ롣

.in +4n
.nf
$ ./execve ./script.sh
argv[0]: ./myecho
argv[1]: script-arg
argv[2]: ./script.sh
argv[3]: hello
argv[4]: world
.fi
.in
.SH Ϣ
.BR chmod (2),
.BR fork (2),
.BR ptrace (2),
.BR execl (3),
.BR fexecve (3),
.BR getopt (3),
.BR environ (7),
.BR credentials (7),
.BR path_resolution (7),
.BR ld.so (8).