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

📄 allman2.ps

📁 Unix操作系统minix 2.0源码
💻 PS
📖 第 1 页 / 共 5 页
字号:
3607(lowest)S3918(numbered)S4368(descriptor)S4819(that)S5018(is)S5133(not)S2376 V1080(currently)S1469(in)S1572(use)S1731(by)S1856(the)S2004(process.)S2544 V1080(The)S1263(object)S1535(referenced)S1988(by)S2114(the)S2263(descriptor)S2692(does)S2902(not)S(distinguish)440 3056 A3522(between)S3884(references)S4326(using)S10 I4569(oldd)S10 R4773(and)S10 I4944(newd)S10 R5183(in)S2664 V1080(any)S1251(way.)S1495(Thus)S1722(if)S10 I1810(newd)S10 R2048(and)S10 I2219(oldd)S10 R2422(are)S(duplicate)369 2571 A2965(references)S3406(to)S3509(an)S3629(open)S3849(\256le,)S10 B4028(read)S10 R4224(\(2\),)S10 B4392(write)S10 R4617(\(2\))S4760(and)S10 B4930(lseek)S10 R5143(\(2\))S2784 V1080(calls)S1295(all)S1426(move)S1679(a)S1754(single)S2024(pointer)S2339(into)S2525(the)S2678(\256le,)S2862(and)S3037(append)S3357(mode,)S(non-blocking)535 3635 A4201(I/O)S4367(and)S(asynchronous)552 4543 A5126(I/O)S2904 V1080(options)S1417(are)S1583(shared)S1888(between)S2266(the)S2431(references.)S2938(If)S3047(a)S3133(separate)S3505(pointer)S3831(into)S4028(the)S4192(\256le)S4362(is)S4470(desired,)S4827(a)S4913(different)S3024 V1080(object)S1357(reference)S1765(to)S1874(the)S2028(\256le)S2188(must)S2414(be)S2540(obtained)S2918(by)S3050(issuing)S3366(an)S(additional)402 3493 A10 B3927(open)S10 R4134(\(2\))S4284(call.)S4512(The)S4701(close-on-exec)S3144 V1080(\257ag)S1256(on)S1381(the)S1529(new)S1722(\256le)S1876(descriptor)S2304(is)S2396(unset.)S3312 V1080(In)S1189(the)S(second)279 1337 A1641(form)S1862(of)S1971(the)S2119(call,)S2315(the)S2463(value)S2706(of)S10 I2815(newd)S10 R3052(desired)S3368(is)S3460(speci\256ed.)S3893(If)S3986(this)S4156(descriptor)S4584(is)S4676(already)S4998(in)S5102(use,)S3432 V1080(the)S1229(descriptor)S1658(is)S1751(\256rst)S1934(deallocated)S2419(as)S2529(if)S2617(a)S10 B2688(close)S10 R2895(\(2\))S3039(call)S3211(had)S3382(been)S(done)195 3598 A3819(\256rst.)S10 I4052(Newd)S10 R4307(is)S4400(not)S4554(closed)S4836(if)S4923(it)S5004(equals)S3552 V10 I1080(oldd)S10 R1266(.)S3720 V9 R720(R)S722(RE)S784(ET)S842(TU)S900(UR)S968(RN)S1030(N)S1121(V)S1123(VA)S1191(AL)S1259(LU)S1317(UE)S1385(E)S3840 V10 R1080(The)S1275(value)S10 R-11531(-)S10 R1588(1)S1676(is)S1781(returned)S2155(if)S2255(an)S2388(error)S2623(occurs)S2924(in)S3040(either)S3308(call.)S3542(The)S3737(external)S4100(variable)S10 B(errno)241 4463 A10 R4742(indicates)S5138(the)S3960 V1080(cause)S1329(of)S1438(the)S1586(error.)S4128 V9 R720(E)S722(ER)S780(RR)S842(RO)S904(OR)S972(RS)S1034(S)S4248 V10 B1080(Dup)S10 R1290(and)S10 B(dup2)218 1460 A10 R1703(fail)S1863(if:)S4416 V1080([EBADF])S10 I1830(Oldd)S10 R2056(or)S10 I2165(newd)S10 R2402(is)S2494(not)S2647(a)S2717(valid)S2943(active)S3209(descriptor)S4584 V1080([EMFILE])S1830(Too)S2017(many)S2265(descriptors)S2732(are)S2881(active.)S4752 V9 R720(N)S722(NO)S790(OT)S858(TE)S916(ES)S974(S)S4872 V10 B1080(Dup)S10 R1290(and)S10 B(dup2)218 1460 A10 R1703(are)S1852(now)S2050(implemented)S2600(using)S2842(the)S10 B2990(F_DUPFD)S10 R3470(function)S3830(of)S10 B3939(fcntl)S10 R4136(\(2\),)S(although)351 4304 A4680(the)S4828(old)S4982(system)S4992 V1080(call)S(interfaces)393 1251 A(still)151 1669 A1845(exist)S2060(to)S(support)301 2163 A2489(old)S2642(programs.)S5160 V9 R720(S)S722(SE)S774(EE)S832(E)S913(A)S915(AL)S983(LS)S1041(SO)S1093(O)S5280 V10 B1080(open)S10 R1287(\(2\),)S10 B1455(close)S10 R1662(\(2\),)S10 B1830(fcntl)S10 R2027(\(2\),)S10 B2195(pipe)S10 R2380(\(2\).)S7903 V720(Page)S941(1)S2669(\()S2711(May)S2920(22,)S(1986)200 3070 A3278(\))S4455(September)S4911(17,)S(1996)200 5061 A8143 VEP%%Page: 1 13BP/slant 0 def/height 0 def480 V10 R720(EXECVE)S1127(\()S1169(2)S1227(\))S2696(Eighth)S(Edition)296 2989 A4720(EXECVE)S5127(\()S5169(2)S5227(\))S960 V9 R720(N)S722(NA)S790(AM)S858(ME)S940(E)S1080 V10 R1080(execve)S10 R-11385(-)S10 R1467(execute)S1800(a)S1870(\256le)S1248 V9 R720(S)S722(SY)S774(YN)S842(NO)S910(OP)S978(PS)S1030(SI)S1082(IS)S1115(S)S1368 V10 B1080(#include)S1482(<unistd.h>)S1608 V1080(int)S1236(execve\(const)S1812(char)S2046(*)S10 I2096(name)S10 B2314(,)S2377(char)S2611(*const)S10 I2923(argv)S10 B3107([],)S3238(char)S3472(*const)S10 I3784(envp)S10 B([]\))102 3974 A1776 V9 R720(D)S722(DE)S790(ES)S848(SC)S900(CR)S962(RI)S1024(IP)S1057(PT)S1109(TI)S1167(IO)S1200(ON)S1268(N)S1896 V10 B1080(Execve)S10 R1420(transforms)S1889(the)S(calling)274 2050 A2362(process)S2702(into)S2896(a)S2980(new)S3187(process.)S3578(The)S3774(new)S3981(process)S4322(is)S4428(constructed)S4931(from)S5166(an)S2016 V1080(ordinary)S1449(\256le)S1606(called)S1875(the)S10 I2026(new)S2216(process)S2551(\256le)S10 R2674(.)S2751(This)S2957(\256le)S3113(is)S3207(either)S3464(an)S3586(executable)S4044(object)S4317(\256le,)S4498(or)S4609(a)S4681(\256le)S4837(of)S4948(data)S5143(for)S2136 V1080(an)S1209(interpreter.)S1714(An)S1871(executable)S2336(object)S2616(\256le)S2779(consists)S3131(of)S3249(an)S3378(identifying)S3853(header,)S4182(followed)S4575(by)S4710(pages)S4974(of)S5093(data)S2256 V1080(representing)S1606(the)S(initial)235 1757 A2020(program)S2389(\(text\))S2636(and)S(initialized)403 2809 A3240(data)S3435(pages.)S(Additional)430 3741 A4198(pages)S4454(may)S4654(be)S4776(speci\256ed)S5161(by)S2376 V1080(the)S1228(header)S1522(to)S1625(be)S(initialized)403 1745 A2173(with)S2377(zero)S2576(data.)S2819(See)S10 B2990(a.out)S10 R3205(\(5\).)S2544 V1080(An)S1231(interpreter)S1680(\256le)S1837(begins)S2127(with)S2334(a)S2407(line)S2586(of)S2698(the)S2849(form)S3074(``#!)S10 I3255(interpreter)S10 R3691(''.)S3838(\(Minix-vmd)S4358(only.\))S4649(When)S4918(an)S5042(inter-)S2664 V1080(preter)S1351(\256le)S1515(is)S10 B1617(execve)S10 R1913('d,)S2056(the)S2213(system)S10 B2526(execve)S10 R2822('s)S2929(the)S3086(speci\256ed)S10 I3478(interpreter)S10 R3914(,)S3973(giving)S4263(it)S4353(the)S4510(name)S4762(of)S4880(the)S5037(origi-)S2784 V1080(nally)S1306(exec'd)S1600(\256le)S1754(as)S1863(an)S1983(argument)S2388(and)S2558(shifting)S2890(over)S3094(the)S3242(rest)S3413(of)S3522(the)S3670(original)S4008(arguments.)S2952 V1080(There)S1353(can)S1530(be)S1662(no)S1799(return)S2077(from)S2310(a)S(successful)414 2392 A10 B2843(execve)S10 R(because)319 3160 A3516(the)S(calling)274 3676 A3987(core)S4198(image)S4481(is)S4585(lost.)S4817(This)S5033(is)S5138(the)S3072 V1080(mechanism)S1563(whereby)S1935(different)S2308(process)S2635(images)S2945(become)S3283(active.)S3240 V1080(The)S1266(argument)S10 I1675(argv)S10 R1888(is)S1984(a)S2058(null-terminated)S2708(array)S2945(of)S3058(character)S3458(pointers)S3811(to)S3918(null-terminated)S4568(character)S4968(strings.)S3360 V1080(These)S1354(strings)S(constitute)391 1655 A2079(the)S2235(argument)S2648(list)S2804(to)S2914(be)S3041(made)S3291(available)S3687(to)S3797(the)S3952(new)S4152(process.)S4536(By)S(convention,)471 4685 A5188(at)S3480 V1080(least)S1293(one)S1467(argument)S1876(must)S2100(be)S2224(present)S2544(in)S2651(this)S2825(array,)S3087(and)S3261(the)S3413(\256rst)S3599(element)S3947(of)S4060(this)S4234(array)S(should)267 4471 A4767(be)S4891(the)S5043(name)S3600 V1080(of)S1189(the)S1337(executed)S1720(program)S2086(\(i.e.,)S2293(the)S2441(last)S(component)446 2606 A3077(of)S10 I3186(name)S10 R3404(\).)S3768 V1080(The)S1281(argument)S10 I1705(envp)S10 R1939(is)S2050(also)S2256(a)S2346(null-terminated)S3012(array)S3265(of)S3394(character)S3810(pointers)S4179(to)S4302(null-terminated)S4968(strings.)S3888 V1080(These)S1349(strings)S1645(pass)S1846(information)S2349(to)S2455(the)S2605(new)S2800(process)S3129(that)S3307(is)S3401(not)S3556(directly)S3891(an)S4013(argument)S4420(to)S4525(the)S4675(command)S5098(\(see)S4008 V10 B1080(environ)S10 R1410(\(7\)\).)S4176 V1080(Descriptors)S1574(open)S1798(in)S1905(the)S(calling)274 2057 A2360(process)S2691(remain)S3000(open)S3224(in)S3331(the)S3483(new)S3680(process,)S4036(except)S4328(for)S4475(those)S4716(for)S4863(which)S5138(the)S4296 V1080(close-on-exec)S1665(\257ag)S1841(is)S1933(set)S2070(\(see)S10 B2258(close)S10 R2465(\(2\)\).)S2692(Descriptors)S3182(that)S3358(remain)S3663(open)S3883(are)S4032(unaffected)S4483(by)S10 B4608(execve)S10 R4888(.)S4464 V(Ignored)313 1080 A1426(signals)S1738(remain)S(ignored)307 2052 A2393(across)S2679(an)S10 B2808(execve)S10 R3088(,)S3147(but)S3309(signals)S3622(that)S3807(are)S(caught)268 3965 A4267(are)S4425(reset)S4650(to)S4762(their)S4981(default)S4584 V1080(values.)S1417(Blocked)S1782(signals)S2090(remain)S2399(blocked)S2746(regardless)S3184(of)S3297(changes)S3650(to)S3757(the)S3909(signal)S4178(action.)S4503(The)S4689(signal)S4958(stack)S5194(is)S4704 V1080(reset)S1296(to)S1399(be)S(unde\256ned)396 1519 A1940(\(see)S10 B2128(sigaction)S10 R2508(\(2\))S2651(for)S2794(more)S3026(information\).)S4872 V1080(Each)S1313(process)S1646(has)S10 I1811(real)S10 R2005(user)S2205(and)S(group)234 2382 A2648(IDs)S2826(and)S3003(an)S10 I3130(effective)S10 R3499(user)S3699(and)S(group)234 3876 A4142(IDs.)S4370(The)S10 I4559(real)S10 R4753(ID)S4892(identi\256es)S4992 V1080(the)S1244(person)S1553(using)S1811(the)S1974(system;)S2321(the)S10 I2484(effective)S10 R2861(ID)S3008(determines)S3490(his)S(access)258 3647 A3945(privileges.)S10 B4432(Execve)S10 R4774(changes)S5138(the)S5112 V1080(effective)S1474(user)S1682(and)S(group)234 1867 A2141(ID)S2288(to)S2406(the)S2569(owner)S2861(of)S2985(the)S3149(executed)S3548(\256le)S3718(if)S3821(the)S3985(\256le)S4155(has)S4330(the)S(set-user-ID)455 4494 A4990(or)S5115(set-)S5232 V(group-ID)375 1080 A1480(modes.)S1817(The)S10 I1999(real)S10 R2186(user)S2379(ID)S2511(is)S2603(not)S2756(affected.)S5400 V1080(The)S1262(new)S1455(process)S1782(also)S1969(inherits)S2296(the)S2444(following)S2860(attributes)S3260(from)S3481(the)S(calling)274 3629 A3928(process:)S5568 V1330(process)S1657(ID)S2770(see)S10 B2924(getpid)S10 R3209(\(2\))S5688 V1330(parent)S1607(process)S1934(ID)S2770(see)S10 B2924(getppid)S10 R3265(\(2\))S5808 V1330(process)S(group)234 1657 A1916(ID)S2770(see)S10 B2924(getpgrp)S10 R3276(\(2\))S5928 V(access)258 1330 A(groups)273 1613 A2770(see)S10 B2924(getgroups)S10 R3365(\(2\))S6048 V1330(working)S1690(directory)S2770(see)S10 B2924(chdir)S10 R3170(\(2\))S6168 V1330(root)S1517(directory)S2770(see)S10 B2924(chroot)S10 R3220(\(2\))S6288 V1330(control)S1640(terminal)S2770(see)S10 B2924(tty)S10 R3058(\(4\))S6408 V1330(alarm)S1585(timer)S2770(see)S10 B2924(alarm)S10 R3197(\(2\))S6528 V1330(\256le)S1484(mode)S1732(mask)S2770(see)S10 B2924(umask)S10 R3225(\(2\))S6648 V1330(signal)S1595(mask)S2770(see)S10 B2924(sigaction)S10 R3320(\(2\),)S10 B3488(sigprocmask)S10 R4046(\(2\))S6816 V1080(When)S1345(the)S1493(executed)S1876(program)S2242(begins,)S2554(it)S2635(is)S2727(called)S2993(as)S3102(follows:)S6984 V10 B1440(int)S1583(main\(int)S10 I1978(argc)S10 B2162(,)S2212(char)S2433(*const)S10 I2732(argv)S10 B2916([],)S3034(char)S3255(*const)S10 I3554(envp)S10 B([]\);)136 3744 A7224 V1440(exit\(main\()S10 I1883(argc)S10 B2067(,)S10 I2117(argv)S10 B2301(,)S10 I2351(envp)S10 B(\)\);)102 2541 A7392 V10 R1080(where)S10 I1365(argc)S10 R1587(is)S1692(the)S1853(number)S2198(of)S2320(elements)S2716(in)S10 I2832(argv)S10 R3054(\(the)S3249(``arg)S(count''\))325 3484 A3847(and)S10 I4030(argv)S10 R4252(is)S4358(the)S4520(array)S4767(of)S4890(character)S7512 V1080(pointers)S1429(to)S1532(the)S1680(arguments)S2124(themselves.)S7903 V720(Page)S941(1)S2669(\()S2711(May)S2920(22,)S(1986)200 3070 A3278(\))S4455(September)S4911(17,)S(1996)200 5061 A

⌨️ 快捷键说明

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