mirror of
https://github.com/boostorg/process.git
synced 2026-01-19 16:32:15 +00:00
Compare commits
664 Commits
boost-1.70
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1dcf21fbde | ||
|
|
2a41d0a0dc | ||
|
|
dc00bf81d6 | ||
|
|
47b5c3c191 | ||
|
|
60affa362c | ||
|
|
aa40c138ed | ||
|
|
c5986d7f57 | ||
|
|
1e572e1756 | ||
|
|
635c226066 | ||
|
|
773ac747d5 | ||
|
|
322f581d1f | ||
|
|
9df0ee099b | ||
|
|
01c9a5b60f | ||
|
|
ed7099687a | ||
|
|
7fb5049feb | ||
|
|
02e14e8fff | ||
|
|
484d6e7a90 | ||
|
|
878a9e6ee9 | ||
|
|
1bfe21baa3 | ||
|
|
1765cd57bb | ||
|
|
7212471b57 | ||
|
|
5597aa0055 | ||
|
|
31d6b5c9f8 | ||
|
|
f5c83eb9c5 | ||
|
|
224e3cf9aa | ||
|
|
bd450f9831 | ||
|
|
c72650df30 | ||
|
|
0c3c79672f | ||
|
|
a7e4fe99c1 | ||
|
|
f9fd327546 | ||
|
|
f372a9a119 | ||
|
|
921bd599b2 | ||
|
|
3999facdd3 | ||
|
|
0ea2eaed27 | ||
|
|
677d94f3a2 | ||
|
|
b8b8d27ac5 | ||
|
|
15555b9664 | ||
|
|
09555dac5f | ||
|
|
818e11672e | ||
|
|
06946018d6 | ||
|
|
cd1621b197 | ||
|
|
1baccf76cd | ||
|
|
06595a2070 | ||
|
|
7e712985c1 | ||
|
|
da08060021 | ||
|
|
afdbab734e | ||
|
|
9dcd1a2775 | ||
|
|
5756891558 | ||
|
|
1d6c9ed0ec | ||
|
|
a941c8e89c | ||
|
|
89d2cc325a | ||
|
|
e637f8483d | ||
|
|
94aa3b6b43 | ||
|
|
d7df711628 | ||
|
|
8ae055bfbd | ||
|
|
ab28b511a9 | ||
|
|
529fb1e222 | ||
|
|
d534ed6c34 | ||
|
|
bb375f50bd | ||
|
|
c329e05fb6 | ||
|
|
b781b49a97 | ||
|
|
a2d2753aa8 | ||
|
|
1b5272a9e1 | ||
|
|
e842a060f1 | ||
|
|
4bb842564f | ||
|
|
359820097b | ||
|
|
b529769eb5 | ||
|
|
d75ffb30ee | ||
|
|
a6f2a1d005 | ||
|
|
e1c6a9b09b | ||
|
|
9bd57d66b7 | ||
|
|
65251a2316 | ||
|
|
298b60caca | ||
|
|
3fd8b2608c | ||
|
|
c33828a166 | ||
|
|
2ccd97cd48 | ||
|
|
7874a04958 | ||
|
|
b5eacaca51 | ||
|
|
2275057574 | ||
|
|
09a978d896 | ||
|
|
5cfdf3ec4c | ||
|
|
c0a23ae2c3 | ||
|
|
64fc05c55d | ||
|
|
0f9dd52f02 | ||
|
|
3fe2033062 | ||
|
|
662c0b10e3 | ||
|
|
fa83c2f9ff | ||
|
|
9925e82a5f | ||
|
|
7f03295c93 | ||
|
|
64c4cdac83 | ||
|
|
58586e420c | ||
|
|
7e5dd4075f | ||
|
|
3ad68a3f2a | ||
|
|
8a8ca8b7ab | ||
|
|
817128108a | ||
|
|
941e93b587 | ||
|
|
e827d14542 | ||
|
|
f218a6a6c1 | ||
|
|
11a0d0d7c1 | ||
|
|
fdfb5043cb | ||
|
|
e46a514629 | ||
|
|
36954338d8 | ||
|
|
a44fd24523 | ||
|
|
eb6b49c090 | ||
|
|
928674d2e3 | ||
|
|
894f371898 | ||
|
|
7ed1648032 | ||
|
|
a96f7a04e0 | ||
|
|
46b71d5e96 | ||
|
|
9f104634a9 | ||
|
|
c492c93062 | ||
|
|
12192d35d3 | ||
|
|
f741b0d120 | ||
|
|
211a3134b6 | ||
|
|
642bd7cf5c | ||
|
|
8df45b8f68 | ||
|
|
54479a7372 | ||
|
|
9761be99bb | ||
|
|
e5e898f363 | ||
|
|
9561ebad1c | ||
|
|
755a3ec78d | ||
|
|
5f80218655 | ||
|
|
3719df39cd | ||
|
|
67a2f97633 | ||
|
|
8b3e90234b | ||
|
|
8044857bb9 | ||
|
|
414d0d6b84 | ||
|
|
2c372461e8 | ||
|
|
2b436127ee | ||
|
|
c342762484 | ||
|
|
c2da58e548 | ||
|
|
aea22dbf6b | ||
|
|
084a85fc6e | ||
|
|
2171367d97 | ||
|
|
67a92df441 | ||
|
|
c773ee16cf | ||
|
|
274fc3163a | ||
|
|
44cae64d49 | ||
|
|
55e2460967 | ||
|
|
bcdd91188c | ||
|
|
e455a12e2c | ||
|
|
e8b5bf17f0 | ||
|
|
20510abc65 | ||
|
|
0058a9c69f | ||
|
|
a26f4fe3c5 | ||
|
|
ff5b383833 | ||
|
|
0379ee6668 | ||
|
|
193384a450 | ||
|
|
406cd3ecf3 | ||
|
|
c6951ff773 | ||
|
|
f2330c195a | ||
|
|
2ae279bd15 | ||
|
|
7a17af0f5c | ||
|
|
768944672f | ||
|
|
46acb247f5 | ||
|
|
08e3549713 | ||
|
|
029ad735fe | ||
|
|
03a348ebdd | ||
|
|
f289f26c87 | ||
|
|
8d9aa1e31d | ||
|
|
1873f34435 | ||
|
|
5f795d9e62 | ||
|
|
f17be678f2 | ||
|
|
b9fc531507 | ||
|
|
69c2c25729 | ||
|
|
8ab2332327 | ||
|
|
ea69cda6d8 | ||
|
|
6b75b4039f | ||
|
|
3c1beb40f6 | ||
|
|
e51970e3bb | ||
|
|
f3f8548dea | ||
|
|
4b7a00d4cf | ||
|
|
c11f31d77e | ||
|
|
3769ec01f4 | ||
|
|
af47f4677c | ||
|
|
cf14d54343 | ||
|
|
b81cac8042 | ||
|
|
c92cce3652 | ||
|
|
d270712fba | ||
|
|
7b6b93691f | ||
|
|
507768e230 | ||
|
|
502dc48753 | ||
|
|
402acc151a | ||
|
|
0503b0997c | ||
|
|
8d372cb510 | ||
|
|
bfb1ebb5bd | ||
|
|
c005adc8fc | ||
|
|
5cab462710 | ||
|
|
ccd46dc692 | ||
|
|
b3c8c3a8da | ||
|
|
4dd6f28094 | ||
|
|
d73f228469 | ||
|
|
ccd1717588 | ||
|
|
9a4aeab97e | ||
|
|
d66dce11bd | ||
|
|
fc38699a4b | ||
|
|
a859c5151c | ||
|
|
8c2f403841 | ||
|
|
6fb2702a79 | ||
|
|
6cd4244f05 | ||
|
|
0c42a58eac | ||
|
|
f269236d38 | ||
|
|
4b413d34f4 | ||
|
|
1403af769b | ||
|
|
964f6d3f7e | ||
|
|
bccf42a3ec | ||
|
|
70c7ae694f | ||
|
|
1fdd405a3f | ||
|
|
af2e884352 | ||
|
|
1fbd8bb5e1 | ||
|
|
09ba5e8d47 | ||
|
|
2c6304b563 | ||
|
|
e79c5f5edd | ||
|
|
7a9ab79162 | ||
|
|
0c1c6dfa90 | ||
|
|
4f9f4c398a | ||
|
|
e4a3e305b4 | ||
|
|
9d51e1cd32 | ||
|
|
f1302430cb | ||
|
|
6f0d6a2e24 | ||
|
|
57b67e0173 | ||
|
|
bbc7eb82e5 | ||
|
|
744e9d95b3 | ||
|
|
bc9a98787e | ||
|
|
0fdd448c67 | ||
|
|
5fcf5465ce | ||
|
|
1dc9d8689e | ||
|
|
dc915be11d | ||
|
|
d7df60938e | ||
|
|
765650aed3 | ||
|
|
f12bc25122 | ||
|
|
32a2c2297c | ||
|
|
3258e3a11c | ||
|
|
ba7e8db9bb | ||
|
|
3211afda4a | ||
|
|
d3f006acd4 | ||
|
|
99633a6e42 | ||
|
|
1e614ee43e | ||
|
|
0e3358705d | ||
|
|
27a35f452d | ||
|
|
8fff7283ed | ||
|
|
611dac143f | ||
|
|
8d93576b94 | ||
|
|
f703845011 | ||
|
|
abd052e09f | ||
|
|
a3304564c6 | ||
|
|
5865c6b449 | ||
|
|
4c872c0a0d | ||
|
|
feabbee098 | ||
|
|
a5b6e70c39 | ||
|
|
347fc68476 | ||
|
|
61ff12c8da | ||
|
|
bd8e81153c | ||
|
|
5fde6bec9f | ||
|
|
cf64f7dc6a | ||
|
|
8355c3e1b6 | ||
|
|
de797e388d | ||
|
|
fc33435f8b | ||
|
|
f45ec624db | ||
|
|
9682056278 | ||
|
|
a00115b454 | ||
|
|
3db86ac69f | ||
|
|
5ffb6bf8da | ||
|
|
2c5a38bfbe | ||
|
|
f28a6406ae | ||
|
|
7a1820d546 | ||
|
|
6bc5add9a7 | ||
|
|
f876ba81e6 | ||
|
|
e943f8fb9c | ||
|
|
bc55a93dce | ||
|
|
2eee42d5e6 | ||
|
|
2d2b124647 | ||
|
|
50986cc330 | ||
|
|
09f0a2c547 | ||
|
|
13af16bfec | ||
|
|
7745fdc687 | ||
|
|
d36f481392 | ||
|
|
011380c28a | ||
|
|
ebd4e723c3 | ||
|
|
b8108c508f | ||
|
|
ecf3dde88c | ||
|
|
4761b375d0 | ||
|
|
ae6a9e6639 | ||
|
|
2c35167d9b | ||
|
|
b68900ca1c | ||
|
|
ba7fe11193 | ||
|
|
b0da4ad10c | ||
|
|
c1b6eb4eb8 | ||
|
|
4ef1792b0a | ||
|
|
1a6956134a | ||
|
|
eb6bce0910 | ||
|
|
9a1c6991c9 | ||
|
|
352b6cf89f | ||
|
|
317b1b7c62 | ||
|
|
a7b65bfc44 | ||
|
|
ee945a6b95 | ||
|
|
992de7b6ea | ||
|
|
6e597b5c8a | ||
|
|
1a1d677d76 | ||
|
|
c1fb7758b2 | ||
|
|
e24af699cf | ||
|
|
e585864cf4 | ||
|
|
69a0615530 | ||
|
|
26f4584e1e | ||
|
|
43e845a691 | ||
|
|
4d59330067 | ||
|
|
f59c1c180e | ||
|
|
618c931188 | ||
|
|
727881649c | ||
|
|
dd4bf8d857 | ||
|
|
9d006cdd94 | ||
|
|
442a6ed8d8 | ||
|
|
686945f46f | ||
|
|
8979836f32 | ||
|
|
4dfc1bd4fd | ||
|
|
f90edf44e1 | ||
|
|
f56e42fd2e | ||
|
|
b9420be981 | ||
|
|
548ea7d999 | ||
|
|
f453d93e83 | ||
|
|
693a33010d | ||
|
|
faad3fa4df | ||
|
|
4e2e580b4c | ||
|
|
d60ea9c4d3 | ||
|
|
a911da2c1f | ||
|
|
f0c98aa97f | ||
|
|
062ac9beb2 | ||
|
|
fb48747fc8 | ||
|
|
f2a0367605 | ||
|
|
3163496b70 | ||
|
|
4e64224ef1 | ||
|
|
25669a78de | ||
|
|
910192e2ad | ||
|
|
15984e3288 | ||
|
|
6aa704c208 | ||
|
|
62d40caddd | ||
|
|
d63d502b40 | ||
|
|
3a401dd306 | ||
|
|
3893a96c6e | ||
|
|
76c393fb8e | ||
|
|
4fce3c8184 | ||
|
|
54b698dcbd | ||
|
|
1f45677518 | ||
|
|
1493e365ed | ||
|
|
5e5e0b8641 | ||
|
|
932ac3038e | ||
|
|
00bc1ccf47 | ||
|
|
257da990d5 | ||
|
|
c6a812e401 | ||
|
|
f93290d3d4 | ||
|
|
a46ab25046 | ||
|
|
1b61ba6ea7 | ||
|
|
27f79e1774 | ||
|
|
0fbfa1cdc1 | ||
|
|
47c4496d05 | ||
|
|
c473251709 | ||
|
|
7bdf11f550 | ||
|
|
dbcc946dac | ||
|
|
e0e801cbb4 | ||
|
|
4943c74e8e | ||
|
|
0733217423 | ||
|
|
397e685053 | ||
|
|
610b337fa3 | ||
|
|
bbb7dced5c | ||
|
|
ab82e78c3d | ||
|
|
a295cd8635 | ||
|
|
b8bcfa2e11 | ||
|
|
ed659bf129 | ||
|
|
4cadf1d333 | ||
|
|
220bec28bf | ||
|
|
ee3c2cfeeb | ||
|
|
221550a848 | ||
|
|
b7821ccf09 | ||
|
|
1f464b3eb5 | ||
|
|
5abb4f4a23 | ||
|
|
722bd31cdb | ||
|
|
e358dc52a2 | ||
|
|
d54788a385 | ||
|
|
4a5d711c86 | ||
|
|
d11e327ab0 | ||
|
|
edaf70a7a7 | ||
|
|
dc8ba65c77 | ||
|
|
ea26c7b2bd | ||
|
|
4d1c438d91 | ||
|
|
d231979a6c | ||
|
|
a3e8600e40 | ||
|
|
c1d0f1be76 | ||
|
|
10c93d88a1 | ||
|
|
5f80e72e9c | ||
|
|
d26ef52519 | ||
|
|
f4d2c260d4 | ||
|
|
e32651a260 | ||
|
|
71aa7d9c00 | ||
|
|
ed3b066da1 | ||
|
|
83380dad79 | ||
|
|
5ad5e82577 | ||
|
|
3acc1a3fa8 | ||
|
|
9bb088ed5d | ||
|
|
cd4ef692e1 | ||
|
|
268795f3c0 | ||
|
|
f8f9c2323c | ||
|
|
0c3ded6636 | ||
|
|
20b328dbf1 | ||
|
|
a60203dac3 | ||
|
|
6d08cb369e | ||
|
|
8dc5ee22f5 | ||
|
|
f7053f31ec | ||
|
|
a13a60d428 | ||
|
|
fa2a522ef2 | ||
|
|
2b39b56efb | ||
|
|
5a283e5200 | ||
|
|
3d5f449052 | ||
|
|
aefb990a7a | ||
|
|
3d092498b2 | ||
|
|
7d7476343a | ||
|
|
e08374ed95 | ||
|
|
155ebdcf1f | ||
|
|
a9925a5d6d | ||
|
|
741d3f4a07 | ||
|
|
f195243a81 | ||
|
|
8c5ab02192 | ||
|
|
b526ac7ce5 | ||
|
|
8222a57744 | ||
|
|
aa3ae06ab7 | ||
|
|
1b4d67170f | ||
|
|
e3594034eb | ||
|
|
ee983eba64 | ||
|
|
0eb4685558 | ||
|
|
7cf1a3b8e6 | ||
|
|
c0a1a82361 | ||
|
|
532951902f | ||
|
|
642c2d369f | ||
|
|
d7a721ee0d | ||
|
|
baa8d3fe7c | ||
|
|
42bdfb5545 | ||
|
|
0f053c323e | ||
|
|
036c9fc4d1 | ||
|
|
b2a96a3e13 | ||
|
|
1dbb3626a9 | ||
|
|
d79e1f2443 | ||
|
|
605dcd19d8 | ||
|
|
6b6a6fa61c | ||
|
|
295e2bdd9c | ||
|
|
dd1513846b | ||
|
|
7a94abfaf2 | ||
|
|
b55a09479c | ||
|
|
5afb20760c | ||
|
|
eec87e1dd9 | ||
|
|
f250a33fb4 | ||
|
|
570cf83a96 | ||
|
|
d52d244f83 | ||
|
|
04ab646f12 | ||
|
|
31c65b5442 | ||
|
|
ebbb6d8b36 | ||
|
|
b9c0140a26 | ||
|
|
27f587a4be | ||
|
|
7f6061c956 | ||
|
|
2f32c95341 | ||
|
|
a8029fc191 | ||
|
|
9f4bd9bce3 | ||
|
|
71f844c24f | ||
|
|
b0b6d67e6f | ||
|
|
3a2576a4d8 | ||
|
|
34eaa262dd | ||
|
|
ce3b3d8f99 | ||
|
|
429f2ba95c | ||
|
|
0c2e7387c8 | ||
|
|
2a2ea4b92d | ||
|
|
873ab2558d | ||
|
|
03571d4eaf | ||
|
|
46ab3ba9b8 | ||
|
|
3aba1f6eb1 | ||
|
|
44771769fa | ||
|
|
8704416941 | ||
|
|
f48392399f | ||
|
|
80f81117aa | ||
|
|
9cff55215d | ||
|
|
2e4b3c2406 | ||
|
|
b510b6a9d9 | ||
|
|
046b96186f | ||
|
|
1df2e67bc4 | ||
|
|
6cf69e2797 | ||
|
|
d3e4cbf3b3 | ||
|
|
e67e49c891 | ||
|
|
29a43b17e4 | ||
|
|
6d10c3a807 | ||
|
|
668579ed6f | ||
|
|
8af828cd43 | ||
|
|
590cc10b42 | ||
|
|
3bc11ce3ac | ||
|
|
603441ecc3 | ||
|
|
612a953369 | ||
|
|
1554773d39 | ||
|
|
dd003bf2b0 | ||
|
|
0341e08297 | ||
|
|
5853345715 | ||
|
|
41f8b1cf00 | ||
|
|
56ae00c7a4 | ||
|
|
f58882c956 | ||
|
|
3f14ebc755 | ||
|
|
1502de1001 | ||
|
|
8541cae396 | ||
|
|
38fa1fd040 | ||
|
|
ba15f760ab | ||
|
|
5e3e8f977e | ||
|
|
6182876d4f | ||
|
|
5bfd2ee08c | ||
|
|
c91b227c47 | ||
|
|
6a4d2ff721 | ||
|
|
6bf37ea8e8 | ||
|
|
ad38cdfada | ||
|
|
167ee79fa9 | ||
|
|
6b83d0b9dd | ||
|
|
16d16d40be | ||
|
|
f5f0866745 | ||
|
|
408cff1997 | ||
|
|
09faec4732 | ||
|
|
5ab43529b7 | ||
|
|
97f5b3c049 | ||
|
|
6dd3e0bdb4 | ||
|
|
eba5cb7be2 | ||
|
|
f4c51bcd5a | ||
|
|
410c0d592e | ||
|
|
40df7899b2 | ||
|
|
51083a8fa8 | ||
|
|
fe3cb0efc7 | ||
|
|
e0dd3b9658 | ||
|
|
d7d84f3952 | ||
|
|
6ccce9104a | ||
|
|
984c0c5b71 | ||
|
|
43523fcf8b | ||
|
|
cf7ad36438 | ||
|
|
ca994c1972 | ||
|
|
0a554c92b5 | ||
|
|
fa81cecffc | ||
|
|
977b76f6aa | ||
|
|
fc1acb82d9 | ||
|
|
db7af9f87d | ||
|
|
a350cc346b | ||
|
|
9fa86d3d65 | ||
|
|
e426f2bfac | ||
|
|
6b173117aa | ||
|
|
ecbc93408f | ||
|
|
6ba9a48d15 | ||
|
|
519c0a636a | ||
|
|
82195c61af | ||
|
|
c604e3a20e | ||
|
|
b27d0170ba | ||
|
|
98fd4eecf0 | ||
|
|
3799315ce7 | ||
|
|
b9431ba492 | ||
|
|
c0dca35615 | ||
|
|
790d79db9c | ||
|
|
5de0a795d1 | ||
|
|
cbaa913e3d | ||
|
|
5786162fb5 | ||
|
|
78c44dd560 | ||
|
|
23ff67d83d | ||
|
|
476c6ccd95 | ||
|
|
28126b3432 | ||
|
|
ed8388d091 | ||
|
|
43c402a5da | ||
|
|
9ff2f6f3ef | ||
|
|
b2a0fadaca | ||
|
|
3c4057204e | ||
|
|
717ac47510 | ||
|
|
4f6f4eb391 | ||
|
|
99e04036c7 | ||
|
|
519e339365 | ||
|
|
d2c930470f | ||
|
|
d5709ae747 | ||
|
|
d2ab81b1b9 | ||
|
|
885557fe01 | ||
|
|
b5b758f89a | ||
|
|
2a954eb809 | ||
|
|
0edff5449a | ||
|
|
417ea77f2f | ||
|
|
9e3fdc9669 | ||
|
|
66c2867371 | ||
|
|
caa7b2fcc8 | ||
|
|
6263e74bcd | ||
|
|
faae08ee64 | ||
|
|
2314e19f12 | ||
|
|
cfd0fc055c | ||
|
|
849b5d0f30 | ||
|
|
d13df2a194 | ||
|
|
86fc3b0b4d | ||
|
|
4733ca719f | ||
|
|
296f12eb64 | ||
|
|
96d3470e37 | ||
|
|
2265c98d81 | ||
|
|
060e5c2526 | ||
|
|
b4894807f1 | ||
|
|
2aa5e1461c | ||
|
|
61fa15fa48 | ||
|
|
92508e06a1 | ||
|
|
e85f0d0816 | ||
|
|
5e90c8de9b | ||
|
|
a486a25a07 | ||
|
|
f8c0dd4da5 | ||
|
|
ee6870bfbc | ||
|
|
0422b6bfb8 | ||
|
|
7fc41b2815 | ||
|
|
a49f1f6e2d | ||
|
|
af54484bc2 | ||
|
|
ebcb30e4bd | ||
|
|
5371c9813b | ||
|
|
9a833c610d | ||
|
|
c99ebfee7a | ||
|
|
34861366e0 | ||
|
|
e6722c452c | ||
|
|
b1e38842fb | ||
|
|
bcc9826e67 | ||
|
|
b6c6753b87 | ||
|
|
0d008a88fc | ||
|
|
f92ec53968 | ||
|
|
00a87d0a67 | ||
|
|
462334639c | ||
|
|
7129182044 | ||
|
|
03fbed44ad | ||
|
|
0277c4fcec | ||
|
|
4bc1ae6ff8 | ||
|
|
266c4503aa | ||
|
|
80479b6b70 | ||
|
|
823a346a08 | ||
|
|
8f3a7b9c63 | ||
|
|
2ebcc07892 | ||
|
|
a673cd9643 | ||
|
|
12971db132 | ||
|
|
94be279992 | ||
|
|
12cded5995 | ||
|
|
0c16a0e5b3 | ||
|
|
e4a6fde7b9 | ||
|
|
92d2bebaaf | ||
|
|
7e7a8cbc1d | ||
|
|
4f767f4bfe | ||
|
|
63f714ae2f | ||
|
|
1b3b9b707c | ||
|
|
f64bc8a6d4 | ||
|
|
102834130d | ||
|
|
fdc6a11cbc | ||
|
|
19b20f55ce | ||
|
|
60d072ce46 | ||
|
|
34f05b9276 | ||
|
|
1b476b0430 | ||
|
|
b294710e60 | ||
|
|
f8cd325d1b | ||
|
|
2a6c23e173 | ||
|
|
d7768b7221 | ||
|
|
b8821eac57 | ||
|
|
d20b64cf37 | ||
|
|
f0ddd6ca29 | ||
|
|
574d9e09d6 | ||
|
|
7085a50f36 | ||
|
|
0485459da2 | ||
|
|
318439af2e | ||
|
|
4d52ff362f | ||
|
|
8d48d9cbfa | ||
|
|
f25c31c847 | ||
|
|
192191ecfb | ||
|
|
3aeb6601cd | ||
|
|
8a7c37617e | ||
|
|
1b6ccb6d39 | ||
|
|
6abce365c5 |
75
.circleci/config.yml
Normal file
75
.circleci/config.yml
Normal file
@@ -0,0 +1,75 @@
|
||||
version: 2
|
||||
|
||||
jobs:
|
||||
build:
|
||||
environment:
|
||||
- BOOST_LIBRARY=process
|
||||
- CXX_STANDARD=gnu++11
|
||||
docker:
|
||||
- image: gcc:7
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Setting up Environment
|
||||
command: |
|
||||
echo 'export BOOST="$HOME/boost-local"' >> $BASH_ENV
|
||||
if [ $CIRCLE_BRANCH = "master" ]; then
|
||||
echo 'export BOOST_BRANCH="master"' >> $BASH_ENV;
|
||||
else
|
||||
echo 'export BOOST_BRANCH="develop"' >> $BASH_ENV;
|
||||
fi
|
||||
echo 'export BOOST_REMOVE="$BOOST/libs/$BOOST_LIBRARY"' >> $BASH_ENV
|
||||
HOME_SED_=$(echo $HOME | sed -e 's/\//\\\//g')
|
||||
echo 'export HOME_SED=$HOME_SED_' >> $BASH_ENV
|
||||
- run:
|
||||
name: install pre dependencies
|
||||
command: |
|
||||
apt-get update -yqq
|
||||
apt-get install git curl valgrind -y
|
||||
- run:
|
||||
name: Initializing git repo for boost
|
||||
command: |
|
||||
git init $BOOST
|
||||
cd $BOOST
|
||||
echo Testing $BRANCH_TO_TEST
|
||||
git remote add --no-tags -t $BOOST_BRANCH origin https://github.com/boostorg/boost.git
|
||||
git fetch --depth=1
|
||||
git checkout $BOOST_BRANCH
|
||||
git submodule update --init --merge
|
||||
git remote set-branches --add origin $BOOST_BRANCH
|
||||
git pull --recurse-submodules
|
||||
git submodule update --init
|
||||
git checkout $BOOST_BRANCH
|
||||
git submodule foreach "git reset --quiet --hard; git clean -fxd"
|
||||
git reset --hard; git clean -fxd
|
||||
git status
|
||||
rm -rf $BOOST_REMOVE
|
||||
mv $HOME/project $BOOST_REMOVE
|
||||
- run:
|
||||
name: Bootstrapping boost-build
|
||||
command: |
|
||||
cd $BOOST
|
||||
./bootstrap.sh
|
||||
./b2 headers
|
||||
- run:
|
||||
name: Building examples
|
||||
command: |
|
||||
cd $BOOST_REMOVE/example
|
||||
../../../b2 -j2 address-model=64 architecture=x86 toolset=gcc cxxflags="-std=gnu++14" -sBOOST_BUILD_PATH=. | tee example.log || FAILED=1
|
||||
sed -i -e "s/^..\/..\/..\/boost\/process\//\/root\/project\/include\/boost\/process\//gm" example.log
|
||||
python <(curl -s https://report.ci/annotate.py) --tool gcc --name "Circle CI Gcc Build" --input example.log
|
||||
exit $FAILED
|
||||
- run:
|
||||
name: Running Unit tests
|
||||
command: |
|
||||
cd $BOOST_REMOVE/test
|
||||
../../../b2 -j2 with-valgrind address-model=64 architecture=x86 testing.launcher=valgrind valgrind=on toolset=gcc cxxflags="--coverage -std=$CXX_STANDARD" linkflags="--coverage" -sBOOST_BUILD_PATH=. | tee test.log || FAILED=1
|
||||
../../../b2 -j2 without-valgrind address-model=64 architecture=x86 toolset=gcc cxxflags="--coverage -std=$CXX_STANDARD" linkflags="--coverage" -sBOOST_BUILD_PATH=. | tee no-valgrind.log || FAILED=1
|
||||
sed -i -e "s/^..\/..\/..\/boost\/process\//\/root\/project\/include\/boost\/process\//gm" test.log
|
||||
sed -i -e "s/^..\/..\/..\/boost\/process\//\/root\/project\/include\/boost\/process\//gm" no-valgrind.log
|
||||
|
||||
python <(curl -s https://report.ci/annotate.py) --tool gcc --input test.log
|
||||
python <(curl -s https://report.ci/annotate.py) --tool gcc --input no-valgrind.log
|
||||
bash <(curl -s https://codecov.io/bash) -x gcov > /dev/null || true
|
||||
echo "BUILD_RESULT: $FAILED"
|
||||
exit $FAILED
|
||||
38
.drone.star
Normal file
38
.drone.star
Normal file
@@ -0,0 +1,38 @@
|
||||
# Use, modification, and distribution are
|
||||
# subject to the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE.txt)
|
||||
#
|
||||
# Copyright Rene Rivera 2020.
|
||||
|
||||
# For Drone CI we use the Starlark scripting language to reduce duplication.
|
||||
# As the yaml syntax for Drone CI is rather limited.
|
||||
#
|
||||
#
|
||||
globalenv={'B2_CI_VERSION': '1', 'B2_VARIANT': 'release'}
|
||||
linuxglobalimage="cppalliance/droneubuntu1804:1"
|
||||
windowsglobalimage="cppalliance/dronevs2019"
|
||||
|
||||
def main(ctx):
|
||||
return [
|
||||
#freebsd_cxx("gcc 11 freebsd", "g++-11", buildtype="boost", buildscript="drone", freebsd_version="13.1", environment={'B2_TOOLSET': 'gcc-11', 'B2_CXXSTD': '17,20', 'B2_LINKFLAGS': '-Wl,-rpath=/usr/local/lib/gcc11'}, globalenv=globalenv),
|
||||
freebsd_cxx("clang 14 freebsd", "clang++-14", buildtype="boost", buildscript="drone", freebsd_version="13.1", environment={'B2_TOOLSET': 'clang-14', 'B2_CXXSTD': '17,20'}, globalenv=globalenv),
|
||||
linux_cxx("docs", "", packages="docbook docbook-xml docbook-xsl xsltproc libsaxonhe-java default-jre-headless flex libfl-dev bison unzip rsync", image="cppalliance/droneubuntu1804:1", buildtype="docs", buildscript="drone", environment={"COMMENT": "docs"}, globalenv=globalenv),
|
||||
linux_cxx("asan", "g++-8", packages="g++-8", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'COMMENT': 'asan', 'B2_VARIANT': 'debug', 'B2_TOOLSET': 'gcc-8', 'B2_CXXSTD': '11', 'B2_ASAN': '1', 'B2_DEFINES': 'BOOST_NO_STRESS_TEST=1', 'DRONE_EXTRA_PRIVILEGED': 'True', 'DRONE_JOB_UUID': '356a192b79'}, globalenv=globalenv, privileged=True),
|
||||
linux_cxx("ubsan", "g++-8", packages="g++-8", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'COMMENT': 'ubsan', 'B2_VARIANT': 'debug', 'B2_TOOLSET': 'gcc-8', 'B2_CXXSTD': '11', 'B2_UBSAN': '1', 'B2_DEFINES': 'BOOST_NO_STRESS_TEST=1', 'B2_LINKFLAGS': '-fuse-ld=gold', 'DRONE_JOB_UUID': '77de68daec'}, globalenv=globalenv),
|
||||
#linux_cxx("gcc 11 arm64", "g++-11", packages="g++-11", buildtype="boost", buildscript="drone", image="cppalliance/droneubuntu2004:multiarch", environment={ 'B2_TOOLSET': 'gcc-11', 'B2_CXXSTD': '11', 'DRONE_JOB_UUID': '17ba079169m'}, arch="arm64", globalenv=globalenv),
|
||||
linux_cxx("GCC 10, Debug + Coverage", "g++-10", packages="g++-10 libssl-dev libffi-dev binutils-gold gdb",
|
||||
image="cppalliance/droneubuntu2004:1", buildtype="boost", buildscript="drone", environment={"GCOV": "gcov-10", "LCOV_VERSION": "1.15", "VARIANT": "process_coverage", "TOOLSET": "gcc", "COMPILER": "g++-10", "CXXSTD": "11", "DRONE_BEFORE_INSTALL" : "process_coverage", "CODECOV_TOKEN": {"from_secret": "codecov_token"}}, globalenv=globalenv, privileged=True),
|
||||
# A set of jobs based on the earlier .travis.yml configuration:
|
||||
linux_cxx("Default clang++ with libc++", "clang++-libc++", packages="libc++-dev", image="cppalliance/droneubuntu1604:1", buildtype="buildtype", buildscript="drone", environment={ "B2_TOOLSET": "clang-7", "B2_CXXSTD": "11", "VARIANT": "debug", "TOOLSET": "clang", "COMPILER": "clang++-libc++", "CXXSTD": "11", "CXX_FLAGS": "<cxxflags>-stdlib=libc++ <linkflags>-stdlib=libc++", "TRAVISCLANG" : "yes" }, globalenv=globalenv),
|
||||
linux_cxx("Default g++", "g++", image="cppalliance/droneubuntu1604:1", buildtype="buildtype", buildscript="drone", environment={ "VARIANT": "release", "TOOLSET": "gcc", "COMPILER": "g++", "CXXSTD": "11" }, globalenv=globalenv),
|
||||
linux_cxx("Clang 3.8, UBasan", "clang++-3.8", packages="clang-3.8 libssl-dev", llvm_os="precise", llvm_ver="3.8", image="cppalliance/droneubuntu1604:1", buildtype="boost", buildscript="drone", environment={"VARIANT": "process_ubasan", "TOOLSET": "clang", "COMPILER": "clang++-3.8", "CXXSTD": "11", "UBSAN_OPTIONS": 'print_stacktrace=1', "DRONE_BEFORE_INSTALL": "UBasan" }, globalenv=globalenv),
|
||||
linux_cxx("gcc 6", "g++-6", packages="g++-6", buildtype="boost", buildscript="drone", image=linuxglobalimage, environment={'B2_TOOLSET': 'gcc-6', 'B2_CXXSTD': '11', 'DRONE_JOB_UUID': '902ba3cda1'}, globalenv=globalenv),
|
||||
linux_cxx("clang 3.8", "clang++-3.8", packages="clang-3.8", buildtype="boost", buildscript="drone", image="cppalliance/droneubuntu1604:1", environment={'B2_TOOLSET': 'clang', 'COMPILER': 'clang++-3.8', 'B2_CXXSTD': '11', 'DRONE_JOB_UUID': '7b52009b64'}, globalenv=globalenv),
|
||||
osx_cxx("clang", "g++", packages="", buildtype="boost", buildscript="drone", environment={'B2_TOOLSET': 'clang', 'B2_CXXSTD': '11,17', 'DRONE_JOB_UUID': '91032ad7bb'}, globalenv=globalenv),
|
||||
linux_cxx("coverity", "g++", packages="", buildtype="coverity", buildscript="drone", image=linuxglobalimage, environment={'COMMENT': 'Coverity Scan', 'B2_TOOLSET': 'clang', 'DRONE_JOB_UUID': '472b07b9fc'}, globalenv=globalenv),
|
||||
windows_cxx("msvc-14.1", "", image="cppalliance/dronevs2017", buildtype="boost", buildscript="drone", environment={ "VARIANT": "release", "TOOLSET": "msvc-14.1", "CXXSTD": "11", "DEFINE" : "BOOST_BEAST_USE_STD_STRING_VIEW", "ADDRESS_MODEL": "64"}),
|
||||
windows_cxx("msvc-14.3", "", image="cppalliance/dronevs2022:1", buildtype="boost", buildscript="drone", environment={ "VARIANT": "release", "TOOLSET": "msvc-14.3", "CXXSTD": "11", "DEFINE" : "BOOST_BEAST_USE_STD_STRING_VIEW", "ADDRESS_MODEL": "64"}),
|
||||
]
|
||||
|
||||
# from https://github.com/boostorg/boost-ci
|
||||
load("@boost_ci//ci/drone/:functions.star", "linux_cxx","windows_cxx","osx_cxx","freebsd_cxx")
|
||||
34
.drone/drone.bat
Executable file
34
.drone/drone.bat
Executable file
@@ -0,0 +1,34 @@
|
||||
@ECHO ON
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
if "%DRONE_JOB_BUILDTYPE%" == "boost" (
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
git clone https://github.com/boostorg/boost-ci.git boost-ci-cloned --depth 1
|
||||
cp -prf boost-ci-cloned/ci .
|
||||
rm -rf boost-ci-cloned
|
||||
|
||||
REM source ci/travis/install.sh
|
||||
REM The contents of install.sh below:
|
||||
|
||||
for /F %%i in ("%DRONE_REPO%") do @set SELF=%%~nxi
|
||||
SET BOOST_CI_TARGET_BRANCH=%DRONE_COMMIT_BRANCH%
|
||||
SET BOOST_CI_SRC_FOLDER=%cd%
|
||||
|
||||
call ci\common_install.bat
|
||||
|
||||
echo '==================================> COMPILE'
|
||||
|
||||
REM set B2_TARGETS=libs/!SELF!/test libs/!SELF!/example
|
||||
set B2_TARGETS=libs/!SELF!/test
|
||||
|
||||
cd !BOOST_ROOT!
|
||||
call bootstrap.bat
|
||||
b2 headers
|
||||
b2 --debug-configuration variant=%VARIANT% cxxstd=%CXXSTD% define=%DEFINE% address-model=%ADDRESS_MODEL% toolset=%TOOLSET% --verbose-test libs/!SELF!/test libs/!SELF!/example -j3
|
||||
) else if "%DRONE_JOB_BUILDTYPE%" == "standalone-windows" (
|
||||
|
||||
REM not used
|
||||
|
||||
)
|
||||
199
.drone/drone.sh
Executable file
199
.drone/drone.sh
Executable file
@@ -0,0 +1,199 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2020 Rene Rivera, Sam Darwin
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
set -xe
|
||||
|
||||
export TRAVIS_BUILD_DIR=$(pwd)
|
||||
export DRONE_BUILD_DIR=$(pwd)
|
||||
export TRAVIS_BRANCH=$DRONE_BRANCH
|
||||
export TRAVIS_EVENT_TYPE=$DRONE_BUILD_EVENT
|
||||
export VCS_COMMIT_ID=$DRONE_COMMIT
|
||||
export GIT_COMMIT=$DRONE_COMMIT
|
||||
export REPO_NAME=$DRONE_REPO
|
||||
export USER=$(whoami)
|
||||
export CC=${CC:-gcc}
|
||||
export PATH=~/.local/bin:/usr/local/bin:$PATH
|
||||
|
||||
common_install () {
|
||||
git clone https://github.com/boostorg/boost-ci.git boost-ci-cloned --depth 1
|
||||
cp -prf boost-ci-cloned/ci .
|
||||
rm -rf boost-ci-cloned
|
||||
|
||||
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
|
||||
unset -f cd
|
||||
fi
|
||||
|
||||
export SELF=`basename $REPO_NAME`
|
||||
export BOOST_CI_TARGET_BRANCH="$TRAVIS_BRANCH"
|
||||
export BOOST_CI_SRC_FOLDER=$(pwd)
|
||||
|
||||
. ./ci/common_install.sh
|
||||
}
|
||||
|
||||
if [ "$DRONE_JOB_BUILDTYPE" == "boost" ]; then
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
common_install
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
$BOOST_ROOT/libs/$SELF/ci/travis/build.sh
|
||||
|
||||
elif [ "$DRONE_JOB_BUILDTYPE" == "docs" ]; then
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
export SELF=`basename $REPO_NAME`
|
||||
|
||||
pwd
|
||||
cd ..
|
||||
mkdir -p $HOME/cache && cd $HOME/cache
|
||||
if [ ! -d doxygen ]; then git clone -b 'Release_1_8_15' --depth 1 https://github.com/doxygen/doxygen.git && echo "not-cached" ; else echo "cached" ; fi
|
||||
cd doxygen
|
||||
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release
|
||||
cd build
|
||||
sudo make install
|
||||
cd ../..
|
||||
if [ ! -f saxonhe.zip ]; then wget -O saxonhe.zip https://sourceforge.net/projects/saxon/files/Saxon-HE/9.9/SaxonHE9-9-1-4J.zip/download && echo "not-cached" ; else echo "cached" ; fi
|
||||
unzip -o saxonhe.zip
|
||||
sudo rm /usr/share/java/Saxon-HE.jar
|
||||
sudo cp saxon9he.jar /usr/share/java/Saxon-HE.jar
|
||||
cd ..
|
||||
BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
git clone -b $BOOST_BRANCH https://github.com/boostorg/boost.git boost-root --depth 1
|
||||
cd boost-root
|
||||
export BOOST_ROOT=$(pwd)
|
||||
git submodule update --init libs/context
|
||||
git submodule update --init tools/boostbook
|
||||
git submodule update --init tools/boostdep
|
||||
git submodule update --init tools/docca
|
||||
git submodule update --init tools/quickbook
|
||||
rsync -av $TRAVIS_BUILD_DIR/ libs/$SELF
|
||||
python tools/boostdep/depinst/depinst.py ../tools/quickbook
|
||||
./bootstrap.sh
|
||||
./b2 headers
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
echo "using doxygen ; using boostbook ; using saxonhe ;" > tools/build/src/user-config.jam
|
||||
./b2 -j3 libs/$SELF/doc//boostrelease
|
||||
|
||||
elif [ "$DRONE_JOB_BUILDTYPE" == "codecov" ]; then
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
common_install
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
cd $BOOST_ROOT/libs/$SELF
|
||||
ci/travis/codecov.sh
|
||||
|
||||
elif [ "$DRONE_JOB_BUILDTYPE" == "valgrind" ]; then
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
common_install
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
cd $BOOST_ROOT/libs/$SELF
|
||||
ci/travis/valgrind.sh
|
||||
|
||||
elif [ "$DRONE_JOB_BUILDTYPE" == "standalone" ]; then
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
# Installing cmake with apt-get, so not required here:
|
||||
# pip install --user cmake
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
export CXXFLAGS="-Wall -Wextra -Werror -std=c++17"
|
||||
mkdir __build_17
|
||||
cd __build_17
|
||||
cmake -DBOOST_JSON_STANDALONE=1 ..
|
||||
cmake --build .
|
||||
ctest -V .
|
||||
export CXXFLAGS="-Wall -Wextra -Werror -std=c++2a"
|
||||
mkdir ../__build_2a
|
||||
cd ../__build_2a
|
||||
cmake -DBOOST_JSON_STANDALONE=1 ..
|
||||
cmake --build .
|
||||
ctest -V .
|
||||
|
||||
elif [ "$DRONE_JOB_BUILDTYPE" == "coverity" ]; then
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
common_install
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
if [ $VARIANT = "process_valgrind" ];
|
||||
then export USE_VALGRIND="testing.launcher=valgrind valgrind=on";
|
||||
fi ;
|
||||
|
||||
if [ -n "${COVERITY_SCAN_NOTIFICATION_EMAIL}" -a \( "$TRAVIS_BRANCH" = "develop" -o "$TRAVIS_BRANCH" = "master" \) -a \( "$DRONE_BUILD_EVENT" = "push" -o "$DRONE_BUILD_EVENT" = "cron" \) ] ; then
|
||||
cd $BOOST_ROOT/libs/$SELF
|
||||
ci/travis/coverity.sh
|
||||
fi
|
||||
|
||||
elif [ "$DRONE_JOB_BUILDTYPE" == "cmake-superproject" ]; then
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
common_install
|
||||
|
||||
echo '==================================> COMPILE'
|
||||
|
||||
export CXXFLAGS="-Wall -Wextra -Werror"
|
||||
|
||||
mkdir __build_static
|
||||
cd __build_static
|
||||
cmake -DBOOST_ENABLE_CMAKE=1 -DBUILD_TESTING=ON -DBoost_VERBOSE=1 \
|
||||
-DBOOST_INCLUDE_LIBRARIES=$SELF ..
|
||||
cmake --build .
|
||||
ctest --output-on-failure -R boost_$SELF
|
||||
|
||||
cd ..
|
||||
|
||||
mkdir __build_shared
|
||||
cd __build_shared
|
||||
cmake -DBOOST_ENABLE_CMAKE=1 -DBUILD_TESTING=ON -DBoost_VERBOSE=1 \
|
||||
-DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=ON ..
|
||||
cmake --build .
|
||||
ctest --output-on-failure -R boost_$SELF
|
||||
|
||||
elif [ "$DRONE_JOB_BUILDTYPE" == "cmake1" ]; then
|
||||
|
||||
echo '==================================> INSTALL'
|
||||
|
||||
pip install --user cmake
|
||||
|
||||
echo '==================================> SCRIPT'
|
||||
|
||||
export SELF=`basename $REPO_NAME`
|
||||
BOOST_BRANCH=develop && [ "$DRONE_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
mkdir -p libs/$SELF
|
||||
cp -r $DRONE_BUILD_DIR/* libs/$SELF
|
||||
# git submodule update --init tools/boostdep
|
||||
git submodule update --init --recursive
|
||||
|
||||
cd libs/$SELF
|
||||
|
||||
../../../b2 -sBOOST_BUILD_PATH=.
|
||||
../../../b2 $MULTITHREAD with-valgrind address-model=64 architecture=x86 $USE_VALGRIND toolset=$TOOLSET cxxflags="--coverage -DBOOST_TRAVISCI_BUILD -std=$CXX_STANDARD" linkflags="--coverage" -sBOOST_BUILD_PATH=. $REPORT_CI
|
||||
../../../b2 $MULTITHREAD without-valgrind address-model=64 architecture=x86 toolset=$TOOLSET cxxflags="--coverage -DBOOST_TRAVISCI_BUILD -std=$CXX_STANDARD" linkflags="--coverage" -sBOOST_BUILD_PATH=. $REPORT_CI
|
||||
|
||||
|
||||
|
||||
fi
|
||||
193
.github/workflows/ci.yml
vendored
Normal file
193
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- feature/**
|
||||
|
||||
env:
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
|
||||
jobs:
|
||||
posix:
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { toolset: gcc-5, cxxstd: "11,14,1z", os: ubuntu-latest, container: 'ubuntu:18.04', install: g++-5 }
|
||||
- { toolset: gcc-6, cxxstd: "11,14,1z", os: ubuntu-latest, container: 'ubuntu:18.04', install: g++-6 }
|
||||
- { toolset: gcc-7, cxxstd: "11,14,17", os: ubuntu-latest, container: 'ubuntu:20.04', install: g++-7 }
|
||||
- { toolset: gcc-10, cxxstd: "11,14,17,2a", os: ubuntu-22.04, install: g++-10 }
|
||||
- { toolset: gcc-12, cxxstd: "11,14,17,20,2b", os: ubuntu-22.04, install: g++-12 }
|
||||
- { toolset: clang, compiler: clang++-3.9, cxxstd: "11,14", os: ubuntu-latest, container: 'ubuntu:18.04', install: clang-3.9 }
|
||||
- { toolset: clang, compiler: clang++-4.0, cxxstd: "11,14", os: ubuntu-latest, container: 'ubuntu:18.04', install: clang-4.0 }
|
||||
- { toolset: clang, compiler: clang++-5.0, cxxstd: "11,14,1z", os: ubuntu-latest, container: 'ubuntu:18.04', install: clang-5.0 }
|
||||
- { toolset: clang, compiler: clang++-6.0, cxxstd: "11,14,17", os: ubuntu-latest, container: 'ubuntu:20.04', install: clang-6.0 }
|
||||
- { toolset: clang, compiler: clang++-7, cxxstd: "11,14,17", os: ubuntu-latest, container: 'ubuntu:20.04', install: clang-7 }
|
||||
- { toolset: clang, compiler: clang++-8, cxxstd: "11,14,17", os: ubuntu-latest, container: 'ubuntu:20.04', install: clang-8 }
|
||||
- { toolset: clang, compiler: clang++-9, cxxstd: "11,14,17,2a", os: ubuntu-latest, container: 'ubuntu:20.04', install: clang-9 }
|
||||
- { toolset: clang, compiler: clang++-10, cxxstd: "11,14,17,2a", os: ubuntu-latest, container: 'ubuntu:20.04', install: clang-10 }
|
||||
- { toolset: clang, compiler: clang++-11, cxxstd: "11,14,17,2a", os: ubuntu-22.04, install: clang-11 }
|
||||
- { toolset: clang, compiler: clang++-12, cxxstd: "11,14,17,2a", os: ubuntu-22.04, install: clang-12 }
|
||||
- { toolset: clang, compiler: clang++-13, cxxstd: "11,14,17,20,2b", os: ubuntu-22.04, install: clang-13 }
|
||||
- { toolset: clang, compiler: clang++-14, cxxstd: "11,14,17,20,2b", os: ubuntu-22.04, install: clang-14 }
|
||||
- { toolset: clang, cxxstd: "11,14,17,2a", os: macos-13 }
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
container:
|
||||
image: ${{matrix.container}}
|
||||
volumes:
|
||||
- /node20217:/node20217:rw,rshared
|
||||
- ${{ startsWith(matrix.container, 'ubuntu:1') && '/node20217:/__e/node20:ro,rshared' || ' ' }}
|
||||
|
||||
steps:
|
||||
- name: Setup container environment
|
||||
if: matrix.container
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get -y install sudo python3 git g++ curl
|
||||
if [[ "${{matrix.container}}" == "ubuntu:1"* ]]; then
|
||||
# Node 20 doesn't work with Ubuntu 16/18 glibc: https://github.com/actions/checkout/issues/1590
|
||||
curl -sL https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.xz | tar -xJ --strip-components 1 -C /node20217
|
||||
fi
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt-get -y install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python3 tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
./bootstrap.sh
|
||||
./b2 -d0 headers
|
||||
|
||||
- name: Create user-config.jam
|
||||
if: matrix.compiler
|
||||
run: |
|
||||
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root
|
||||
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
|
||||
|
||||
alpine-linux:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: alpine:3.20.1
|
||||
steps:
|
||||
- name: Install packages
|
||||
run: apk add g++ git python3 linux-headers
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python3 tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
./bootstrap.sh
|
||||
./b2 -d0 headers
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root
|
||||
./b2 -j3 libs/$LIBRARY/test toolset=gcc cxxstd=23 variant=debug,release
|
||||
|
||||
windows:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: msvc-14.0
|
||||
cxxstd: "14,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.2
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.3
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: clang-win
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: gcc
|
||||
cxxstd: "11,14,17,2a"
|
||||
addrmd: 64
|
||||
os: windows-2019
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
|
||||
- name: Run tests
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -31,4 +31,5 @@
|
||||
/notes.cpp
|
||||
/notes_p.txt
|
||||
.settings
|
||||
.DS_Store
|
||||
|
||||
|
||||
14
.travis.yml
14
.travis.yml
@@ -23,8 +23,6 @@ os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
secure: "vs7qgXb0lQg8CTyDPSi3RQtOIOtssaCkBIx86UoEvTXwJCTOLPe7ZufQ0lobn0OVWo261AMx9GbumBBzqfsvJc1G6ixGBVwymiGli/R8DZDvvg9UdljsEk65s/XbujE/9qh97zKGGioFyCn1Bmf5+SdDAxsuXTZm/cBny5VxYaaCR7s2cFUmp4up/djqg1GI7uwBh3ceodT3OL1X3dlMV59gOJWWNsB+RO9b9DPhTW7nOlMNRiEFik4rweecQB0JS8LaHDjYwzIRrGYHX+lR9cE/O8GCCHcUOmq9jCozDdxx+HZRu4rb1ST1RiDbvYaoeTif0Df1fVXHWOoO2D4NlXB6tJPXw2mkop00j6zkcydUJYid6T1lwfEpXAhd5A9FvOIXO5hoju1wlqfkU2eFQ9Na8z8bCIX2niZmveZWp4Ag52gEPzJMFx9hHGT8J4FWMvkqTWezux1sPZrjZjc0kXdJrIp84D9MsBc1sKrxOAOb5ekSfIK5n4JDkgUtuwMSTvEdWqNJXFPZq1rEu4GTwX99z3/XF+pM5XaCDQtZ/zUA5SPHhy0dKLH/BvceUqLJt53+lMcpsltJDB+XxQ/CFL7IdgR91OKGus/z4dbVWiSdkoNvcuZqjQLFLOMVNxoqC6PRvDAEhpy21j/5GUPvM5baQS7IEin0NF7bOTtXJdY="
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- BADGE=linux
|
||||
@@ -73,7 +71,7 @@ before_install:
|
||||
# Set this to the name of the library
|
||||
- PROJECT_TO_TEST=`basename $TRAVIS_BUILD_DIR`
|
||||
- echo "Testing $PROJECT_TO_TEST"
|
||||
- if [ $TRAVIS_OS_NAME = "osx" ]; then brew install gcc5; brew install valgrind; brew install llvm; TOOLSET=clang; BOOST_TEST_CATCH_SYSTEM_ERRORS=no; MULTITHREAD=-j8; else TOOLSET=gcc-5; USE_VALGRIND="testing.launcher=valgrind valgrind=on"; fi
|
||||
- if [ $TRAVIS_OS_NAME = "osx" ]; then brew install gcc5; brew install valgrind; brew install llvm; TOOLSET=clang; BOOST_TEST_CATCH_SYSTEM_ERRORS=no; MULTITHREAD=-j8; else TOOLSET=gcc-5; REPORT_CI=--boost-process-report-ci USE_VALGRIND="testing.launcher=valgrind valgrind=on"; fi
|
||||
# Cloning Boost libraries (fast nondeep cloning)
|
||||
- BOOST=$HOME/boost-local
|
||||
- git init $BOOST
|
||||
@@ -87,7 +85,7 @@ before_install:
|
||||
- git checkout $BOOST_BRANCH
|
||||
- git submodule update --init --merge
|
||||
- git remote set-branches --add origin $BOOST_BRANCH
|
||||
- git pull --recurse-submodules
|
||||
- git pull --recurse-submodules || true
|
||||
- git submodule update --init
|
||||
- git checkout $BOOST_BRANCH
|
||||
- git submodule foreach "git reset --quiet --hard; git clean -fxd"
|
||||
@@ -103,8 +101,8 @@ before_install:
|
||||
- echo BOOST_TEST_CATCH_SYSTEM_ERRORS $BOOST_TEST_CATCH_SYSTEM_ERRORS
|
||||
script:
|
||||
# `--coverage` flags required to generate coverage info for Coveralls
|
||||
- ../../../b2 $MULTITHREAD with-valgrind address-model=64 architecture=x86 $USE_VALGRIND toolset=$TOOLSET cxxflags="--coverage -DBOOST_TRAVISCI_BUILD -std=$CXX_STANDARD" linkflags="--coverage" -sBOOST_BUILD_PATH=.
|
||||
- ../../../b2 $MULTITHREAD without-valgrind address-model=64 architecture=x86 toolset=$TOOLSET cxxflags="--coverage -DBOOST_TRAVISCI_BUILD -std=$CXX_STANDARD" linkflags="--coverage" -sBOOST_BUILD_PATH=.
|
||||
- ../../../b2 $MULTITHREAD with-valgrind address-model=64 architecture=x86 $USE_VALGRIND toolset=$TOOLSET cxxflags="--coverage -DBOOST_TRAVISCI_BUILD -std=$CXX_STANDARD" linkflags="--coverage" -sBOOST_BUILD_PATH=. $REPORT_CI
|
||||
- ../../../b2 $MULTITHREAD without-valgrind address-model=64 architecture=x86 toolset=$TOOLSET cxxflags="--coverage -DBOOST_TRAVISCI_BUILD -std=$CXX_STANDARD" linkflags="--coverage" -sBOOST_BUILD_PATH=. $REPORT_CI
|
||||
after_success:
|
||||
# Copying Coveralls data to a separate folder
|
||||
- mkdir -p $TRAVIS_BUILD_DIR/coverals
|
||||
@@ -133,4 +131,6 @@ after_success:
|
||||
- coveralls-lcov coverals/coverage.info
|
||||
|
||||
after_script:
|
||||
- curl -s https://report.ci/upload.py | python - --token=$REPORT_CI_TOKEN --name="$BADGE test run"
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
- cd $BOOST/libs/$PROJECT_TO_TEST/test
|
||||
- curl -s https://report.ci/report.py | python - --name="$BADGE test run"
|
||||
|
||||
74
CMakeLists.txt
Normal file
74
CMakeLists.txt
Normal file
@@ -0,0 +1,74 @@
|
||||
# Generated by `boostdep --cmake process`
|
||||
# Copyright 2020 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.8...3.31)
|
||||
|
||||
project(boost_process VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
|
||||
option(BOOST_PROCESS_USE_STD_FS "Use std::filesystem instead of Boost.Filesystem" OFF)
|
||||
|
||||
add_library(boost_process
|
||||
src/detail/environment_posix.cpp
|
||||
src/detail/environment_win.cpp
|
||||
src/detail/last_error.cpp
|
||||
src/detail/process_handle_windows.cpp
|
||||
src/detail/throw_error.cpp
|
||||
src/detail/utf8.cpp
|
||||
src/ext/cmd.cpp
|
||||
src/ext/cwd.cpp
|
||||
src/ext/env.cpp
|
||||
src/ext/exe.cpp
|
||||
src/ext/proc_info.cpp
|
||||
src/posix/close_handles.cpp
|
||||
src/windows/default_launcher.cpp
|
||||
src/environment.cpp
|
||||
src/error.cpp
|
||||
src/pid.cpp
|
||||
src/shell.cpp)
|
||||
|
||||
add_library(Boost::process ALIAS boost_process)
|
||||
|
||||
target_include_directories(boost_process PUBLIC include)
|
||||
target_link_libraries(boost_process
|
||||
PUBLIC
|
||||
Boost::algorithm
|
||||
Boost::asio
|
||||
Boost::config
|
||||
Boost::core
|
||||
Boost::fusion
|
||||
Boost::iterator
|
||||
Boost::move
|
||||
Boost::optional
|
||||
Boost::system
|
||||
Boost::tokenizer
|
||||
Boost::type_index
|
||||
Boost::winapi
|
||||
)
|
||||
|
||||
target_compile_definitions(boost_process
|
||||
PRIVATE BOOST_PROCESS_SOURCE=1
|
||||
)
|
||||
|
||||
if(BOOST_PROCESS_USE_STD_FS)
|
||||
target_compile_definitions(boost_process PUBLIC BOOST_PROCESS_USE_STD_FS)
|
||||
target_compile_features(boost_process PUBLIC cxx_std_17)
|
||||
else()
|
||||
target_link_libraries(boost_process PUBLIC Boost::filesystem)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(boost_process PUBLIC ntdll shell32 advapi32 user32 ws2_32)
|
||||
endif()
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(boost_process PUBLIC BOOST_PROCESS_DYN_LINK)
|
||||
else()
|
||||
target_compile_definitions(boost_process PUBLIC BOOST_PROCESS_STATIC_LINK)
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
17
README.md
17
README.md
@@ -1,18 +1,21 @@
|
||||
# [Boost Process (Boost.Process)](https://github.com/klemens-morgenstern/boost-process)
|
||||
# [Boost Process (Boost.Process)](https://github.com/boostorg/process)
|
||||
|
||||
Boost.process is a library for comfortable management of processes, released with boost 1.64.0.
|
||||
|
||||
### Test results
|
||||
|
||||
Branches | Linux | OSX | Windows | Code coverage | Matrix |
|
||||
----------------|-------|-----|---------| ------------- |--------|
|
||||
Develop: | [](https://travis-ci.org/klemens-morgenstern/boost-process) [](https://api.report.ci/status/klemens-morgenstern/boost-process?branch=develop&build=linux) | [](https://travis-ci.org/klemens-morgenstern/boost-process) [](https://api.report.ci/status/klemens-morgenstern/boost-process?branch=develop&build=osx) | [](https://ci.appveyor.com/project/klemens-morgenstern/boost-process/branch/develop) [](https://api.report.ci/status/klemens-morgenstern/boost-process?branch=develop&build=windows) | [](https://coveralls.io/github/klemens-morgenstern/boost-process?branch=develop) | [](http://www.boost.org/development/tests/develop/developer/process.html)
|
||||
Master: | [](https://travis-ci.org/klemens-morgenstern/boost-process) [](https://api.report.ci/status/klemens-morgenstern/boost-process?branch=master&build=linux) | [](https://travis-ci.org/klemens-morgenstern/boost-process) [](https://api.report.ci/status/klemens-morgenstern/boost-process?branch=master&build=osx) | [](https://ci.appveyor.com/project/klemens-morgenstern/boost-process/branch/master) [](https://api.report.ci/status/klemens-morgenstern/boost-process?branch=master&build=windows) | [](https://coveralls.io/github/klemens-morgenstern/boost-process?branch=master) | [](http://www.boost.org/development/tests/master/developer/process.html)
|
||||
| Branches | Linux / Windows | Code coverage | Matrix |
|
||||
|----------|----------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| Develop: | [](https://drone.cpp.al/boostorg/process) | [](https://codecov.io/gh/boostorg/process) | [](https://regression.boost.io/develop/developer/process.html) |
|
||||
| Master: | [](https://drone.cpp.al/boostorg/process) | [](https://codecov.io/gh/boostorg/process) | [](https://regression.boost.io/master/developer/process.html) |
|
||||
|
||||
|
||||
[Open Issues](https://github.com/klemens-morgenstern/boost-process/issues)
|
||||
|
||||
[Latest developer documentation](http://klemens-morgenstern.github.io/process/)
|
||||
|
||||
|
||||
[Open Issues](https://github.com/boostorg/process/issues)
|
||||
|
||||
[Latest developer documentation](https://www.boost.org/doc/libs/develop/doc/html/process.html)
|
||||
|
||||
### About
|
||||
This C++11 library is the current result of a long attempt to get a boost.process library, which is going on since 2006.
|
||||
|
||||
47
build.jam
Normal file
47
build.jam
Normal file
@@ -0,0 +1,47 @@
|
||||
# Copyright René Ferdinand Rivera Morell 2024
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
require-b2 5.2 ;
|
||||
|
||||
import feature : feature ;
|
||||
|
||||
feature boost.process.fs : boost std : optional propagated ;
|
||||
feature boost.process.disable-close-range : on off : optional ;
|
||||
|
||||
constant boost_dependencies :
|
||||
/boost/algorithm//boost_algorithm
|
||||
/boost/asio//boost_asio
|
||||
/boost/assert//boost_assert
|
||||
/boost/config//boost_config
|
||||
/boost/core//boost_core
|
||||
/boost/fusion//boost_fusion
|
||||
/boost/io//boost_io
|
||||
/boost/iterator//boost_iterator
|
||||
/boost/move//boost_move
|
||||
/boost/optional//boost_optional
|
||||
/boost/system//boost_system
|
||||
/boost/throw_exception//boost_throw_exception
|
||||
/boost/tokenizer//boost_tokenizer
|
||||
/boost/type_index//boost_type_index
|
||||
/boost/type_traits//boost_type_traits
|
||||
/boost/utility//boost_utility
|
||||
/boost/winapi//boost_winapi ;
|
||||
|
||||
project /boost/process
|
||||
: common-requirements
|
||||
<include>include
|
||||
: default-build
|
||||
<boost.process.fs>boost
|
||||
;
|
||||
|
||||
explicit
|
||||
[ alias boost_process : build//boost_process ]
|
||||
[ alias all : boost_process example example/v2 test ]
|
||||
;
|
||||
|
||||
call-if : boost-library process
|
||||
: install boost_process
|
||||
;
|
||||
|
||||
73
build/Jamfile
Normal file
73
build/Jamfile
Normal file
@@ -0,0 +1,73 @@
|
||||
# Copyright (c) 2024 Klemens D. Morgenstern
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
import os ;
|
||||
import feature ;
|
||||
import-search /boost/config/checks ;
|
||||
import config : requires ;
|
||||
|
||||
project : requirements
|
||||
<define>BOOST_ASIO_NO_DEPRECATED
|
||||
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
|
||||
<toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
|
||||
<toolset>msvc:<cxxflags>/bigobj
|
||||
<target-os>windows:<define>WIN32_LEAN_AND_MEAN
|
||||
<target-os>linux:<linkflags>-lpthread
|
||||
: source-location ../src
|
||||
: common-requirements
|
||||
<library>$(boost_dependencies)
|
||||
<boost.process.fs>std:<define>BOOST_PROCESS_USE_STD_FS=1
|
||||
;
|
||||
|
||||
alias process_sources
|
||||
: detail/environment_posix.cpp
|
||||
detail/environment_win.cpp
|
||||
detail/last_error.cpp
|
||||
detail/process_handle_windows.cpp
|
||||
detail/throw_error.cpp
|
||||
detail/utf8.cpp
|
||||
ext/cmd.cpp
|
||||
ext/cwd.cpp
|
||||
ext/env.cpp
|
||||
ext/exe.cpp
|
||||
ext/proc_info.cpp
|
||||
posix/close_handles.cpp
|
||||
windows/default_launcher.cpp
|
||||
environment.cpp
|
||||
error.cpp
|
||||
pid.cpp
|
||||
shell.cpp
|
||||
;
|
||||
|
||||
lib shell32 ;
|
||||
lib advapi32 ;
|
||||
lib ntdll ;
|
||||
lib user32 ;
|
||||
lib ws2_32 ;
|
||||
|
||||
lib kvm ;
|
||||
lib procstat ;
|
||||
|
||||
lib boost_process
|
||||
: process_sources
|
||||
: requirements <define>BOOST_PROCESS_SOURCE=1
|
||||
<link>shared:<define>BOOST_PROCESS_DYN_LINK=1
|
||||
<boost.process.fs>boost:<library>/boost/filesystem//boost_filesystem
|
||||
<boost.process.disable-close-range>on:<define>BOOST_PROCESS_V2_POSIX_FORCE_DISABLE_CLOSE_RANGE=1
|
||||
<target-os>windows:<library>shell32
|
||||
<target-os>windows:<library>user32
|
||||
<target-os>windows:<library>ntdll
|
||||
<target-os>windows:<library>advapi32
|
||||
<target-os>windows:<library>ws2_32
|
||||
<target-os>bsd:<library>kvm
|
||||
<target-os>freebsd:<library>kvm
|
||||
<target-os>freebsd:<library>procstat
|
||||
<target-os>netbsd:<library>kvm
|
||||
<target-os>openbsd:<library>kvm
|
||||
<target-os>solaris:<library>kvm
|
||||
: usage-requirements
|
||||
<link>shared:<define>BOOST_PROCESS_DYN_LINK=1
|
||||
<boost.process.fs>boost:<library>/boost/filesystem//boost_filesystem
|
||||
;
|
||||
@@ -1,64 +1,31 @@
|
||||
# Copyright (c) 2006, 2007 Julio M. Merino Vidal
|
||||
# Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
|
||||
# Copyright (c) 2009 Boris Schaeling
|
||||
# Copyright (c) 2010 Felipe Tanus, Boris Schaeling
|
||||
# Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
# Copyright 2022 Klemens D. Morgenstern
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
using boostbook ;
|
||||
using quickbook ;
|
||||
using doxygen ;
|
||||
import asciidoctor ;
|
||||
|
||||
html index.html : index.adoc ;
|
||||
|
||||
local images = [ glob images/*.svg ] ;
|
||||
install images : $(images) : <location>html/boost_process ;
|
||||
install images_glob : $(images) : <location>$(BOOST_ROOT)/doc/html/boost_process ;
|
||||
install html_ : index.html : <location>html ;
|
||||
|
||||
import type ;
|
||||
type.register XMLPROCESSWORKAROUND : : XML ;
|
||||
import generators ;
|
||||
generators.register-standard common.copy : XML : XMLPROCESSWORKAROUND ;
|
||||
pdf process.pdf : index.adoc ;
|
||||
explicit process.pdf ;
|
||||
|
||||
xmlprocessworkaround posix_pseudocode : posix_pseudocode.xml ;
|
||||
xmlprocessworkaround windows_pseudocode : windows_pseudocode.xml ;
|
||||
install pdf_ : process.pdf : <location>pdf ;
|
||||
explicit pdf_ ;
|
||||
|
||||
install images
|
||||
:
|
||||
images/posix_exec_err.svg
|
||||
images/posix_fork_err.svg
|
||||
images/posix_success.svg
|
||||
images/windows_exec.svg
|
||||
:
|
||||
<location>html/images
|
||||
;
|
||||
|
||||
doxygen autodoc
|
||||
:
|
||||
../../../boost/process.hpp
|
||||
[ glob ../../../boost/process/*.hpp ]
|
||||
:
|
||||
<doxygen:param>EXCLUDE_SYMBOLS=BOOST_ASIO_INITFN_RESULT_TYPE
|
||||
<doxygen:param>PREDEFINED=BOOST_PROCESS_DOXYGEN
|
||||
<doxygen:param>HIDE_UNDOC_CLASSES=YES
|
||||
<doxygen:param>HIDE_UNDOC_MEMBERS=YES
|
||||
<doxygen:param>EXAMPLE_PATH=.
|
||||
<dependency>posix_pseudocode
|
||||
<dependency>windows_pseudocode
|
||||
<xsl:path>.
|
||||
;
|
||||
|
||||
|
||||
|
||||
boostbook standalone
|
||||
:
|
||||
process.qbk
|
||||
:
|
||||
<dependency>autodoc
|
||||
<dependency>images
|
||||
<dependency>images_glob
|
||||
<xsl:param>boost.root=../../../..
|
||||
<xsl:param>html.stylesheet=../../../../doc/src/boostbook.css
|
||||
;
|
||||
|
||||
###############################################################################
|
||||
alias boostdoc
|
||||
: standalone/<format>docbook
|
||||
:
|
||||
: <dependency>images_glob
|
||||
: ;
|
||||
alias boostdoc ;
|
||||
explicit boostdoc ;
|
||||
alias boostrelease ;
|
||||
explicit boostrelease ;
|
||||
alias boostrelease : html_ ;
|
||||
explicit boostrelease ;
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
[section Acknowledgements]
|
||||
= Acknowledgements
|
||||
|
||||
The first Boost.Process draft was created in 2006. A lof of people have worked on various drafts since then. Especially Merino Vidal, Ilya Sokolov and Felipe Tanus spent a lot of time working on early drafts. They influenced Boost.Process over the years and wrote code which, to various extents, is still around in the library today.
|
||||
|
||||
The design of earlier versions of Boost.Process was not always satisfying. In 2011 Jeff Flinn proposed the executor and initializer concepts Boost.Process is based on today. Without Jeff's idea the overall design of Boost.Process would not look like it does today.
|
||||
|
||||
A special thank you goes to [@http://www.intra2net.com/ Intra2net AG] (especially Thomas Jarosch) who sponsored a project to support the development of Boost.Process. It was this sponsorship which made it possible to create a new Boost.Process version in 2012.
|
||||
A special thank you goes to [http://www.intra2net.com/(Intra2net AG) (especially Thomas Jarosch) who sponsored a project to support the development of Boost.Process. It was this sponsorship which made it possible to create a new Boost.Process version in 2012.
|
||||
|
||||
Great thanks also goes to Boris Schaeling, who despite having boost.process rejected, went on to work on it and maintained it up until this day and participated in the development of the current version.
|
||||
|
||||
[endsect]
|
||||
Many Thanks, to [https://github.com/samuelvenable](Samuel Venable) for contributing the <<v2::ext>> functionality and all the research that went into it.
|
||||
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
[section:concepts Concepts]
|
||||
In this section, some of the underlying concepts of the operating system used in this library, will be explained.
|
||||
In the following chapters we will presume knowledge of that. Though please note,
|
||||
that this is a short summary and not conclusive of everything that can be done.
|
||||
|
||||
The goal of this library is to implement a portable wrapper, so that we will explain mostly what
|
||||
windows and posix have in common.
|
||||
|
||||
[section:pipes Pipes]
|
||||
Pipes are a facility for communication between different threads, processes and in some cases machines, the operating system provides.
|
||||
|
||||
The typical feature of a pipe is, that it is one channel, to which two handles are given, one for reading (source), one for writing (sink).
|
||||
In that it is different than other facilities (like sockets) and provides another way to manage the connectivity: if one side of the pipe is closed
|
||||
(i.e. the pipe is broken), the other is notified.
|
||||
|
||||
Pipes are typically used for interprocess communication. The main reason is, that pipes can be directly assigned to the process stdio, i.e. stderr, stdin and stdout.
|
||||
Additionally, half of the pipe can be inherited to the child process and closed in the father process. This will cause the pipe to be broken when the child process exits.
|
||||
|
||||
Though please not, that if the the same thread reads and write to a pipe, it will only talk to itself.
|
||||
|
||||
[section:anonymous Anonymous Pipes]
|
||||
|
||||
The usual type of pipes, are the anonymous ones. Since the have no name,
|
||||
a handle to them can only be obtained from duplicating either handle.
|
||||
|
||||
In this library the following functions are used for the creation of unnamed pipes:
|
||||
|
||||
* [@http://pubs.opengroup.org/onlinepubs/7908799/xsh/pipe.html posix]
|
||||
* [@https://msdn.microsoft.com/de-de/library/windows/desktop/aa365152.aspx windows]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:named Named Pipes]
|
||||
|
||||
As the name suggests, named pipes have a string identifier. This means that a
|
||||
handle to them can be obtained with the identifier, too.
|
||||
|
||||
The implementation on posix uses [@(http://pubs.opengroup.org/onlinepubs/009695399/functions/mkfifo.html fifos],
|
||||
which means, that the named pipe behaves like a file.
|
||||
|
||||
Windows does provide a facility called [@https://msdn.microsoft.com/en-us/library/windows/desktop/aa365150(v=vs.85).aspx named pipes],
|
||||
which also have file-like names, but are in a different scope than the actual file system.
|
||||
|
||||
[note The main reason named pipes are part of this library, is because they need to be internally used for asynchrounous communication on windows.]
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
[section:process Processes]
|
||||
|
||||
A process is an independently executable entity, which is different from a thread, in that it has its own resources.
|
||||
Those include memory and hardware resources.
|
||||
|
||||
Every process is identified by a unique number[footnote it is unique as long as the process is active], called the process identification digit, `pid`.
|
||||
|
||||
[section:exit_code Exit code]
|
||||
A process will return an integer value indicating whether it was successful. On posix
|
||||
there are more codes associated with that, but not so on windows. Therefore there is not such encoding currently in the library.
|
||||
However an exit code of zero means the process was successful, while one different than zero indicates an error.
|
||||
[endsect]
|
||||
|
||||
[section:termination Termination]
|
||||
Processes can also be forced to exit. There are two ways to do this, signal the process to so and wait, and just terminate the process without conditions.
|
||||
|
||||
Usually the first approach is to signal an exit request, but windows - unlike posix - does not provide a consistent way to do this. Hence this is not part of the
|
||||
library and only the hard terminate is.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:env Environment]
|
||||
|
||||
The environment is a map of variables local to every process. The most significant one for this library
|
||||
is the `PATH` variable, which contains a list of paths, that ought to be searched for executables. A shell will do this automatically,
|
||||
while this library provides a function for that.
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
11
doc/configuration.adoc
Normal file
11
doc/configuration.adoc
Normal file
@@ -0,0 +1,11 @@
|
||||
= Configuration
|
||||
|
||||
Boost process v2 can be configured in the following ways:
|
||||
|
||||
[cols="1,1"]
|
||||
|===
|
||||
| Macro | Description
|
||||
|
||||
| `BOOST_PROCESS_V2_STANDALONE` | Build boost.process for standalone asio
|
||||
| `BOOST_PROCESS_USE_STD_FS` | Use std::filesystem instead of boost::filesystem
|
||||
| `BOOST_PROCESS_V2_POSIX_FORCE_DISABLE_CLOSE_RANGE` | Disable usage of `close_range`.
|
||||
@@ -1,94 +0,0 @@
|
||||
[section:design Design Rationale]
|
||||
[section Scope]
|
||||
This library is meant to give an wrapper around the different OS-specific methods
|
||||
to launch processes. Its aim is to provide all functionality that is available on
|
||||
those systems and allow the user to do all related things, which require using the OS APIs.
|
||||
|
||||
[*This library does not try to provide a full library for everything process related]
|
||||
In many discussions the proposal was made to build boost.process into a DSEL [footnote Domain Specific Embedded Language] of some sort.
|
||||
This is not the goal, it rather provides the facilities to build such a DSEL-Library on top of it.
|
||||
Therefore the library also does [*not] force any particular use (such as only asynchronous communication) on its user.
|
||||
It rather could be integrated with such a library.
|
||||
|
||||
[endsect]
|
||||
[section Interface Style]
|
||||
|
||||
Boost.Process does use a very particular style when constructing a process.
|
||||
This is because a process holds many properties, which are not members of the actual child class.
|
||||
Those properties are in many cases not accessible by the father process, for example when using environments.
|
||||
Here the child process can modify its own environment, but there is no way for the father process to know.
|
||||
That means, that a child process has properties that cannot be accessed in C++.
|
||||
|
||||
This now leads to the two styles supported and mixed by this library. Overloading and properties.
|
||||
Consider that you may want to launch a process passing a number of arguments. This is supported in both styles, and would look like this:
|
||||
|
||||
```
|
||||
system("gcc", "--version"); //overloading
|
||||
system("gcc", args={"--version"}); //property style.
|
||||
```
|
||||
|
||||
Both styles can also be mixed in some cases.
|
||||
|
||||
```
|
||||
system("gcc", "-c", args+={"main.cpp"});
|
||||
```
|
||||
|
||||
In the following section the avaible styles will be described. Note that the
|
||||
overload style is implemented via type traits, so the types will be listed.
|
||||
|
||||
[caution There is no guarantee in which order the arguments will be applied!
|
||||
There is however a guarantee for arguments belonging together, i.e. the string
|
||||
argument and the args property will be evaluated in the order given.]
|
||||
|
||||
[endsect]
|
||||
[section:arg_cmd_style Arguments/Command Style]
|
||||
|
||||
When passing arguments to the process, two styles are provided, the cmd-style and the exe-/args-style.
|
||||
|
||||
The cmd style will interpret the string as a sequence of the exe and arguments and parse them as such, while the exe-/args-style will
|
||||
interpret each string as an argument.
|
||||
|
||||
[table:id Cmd vs Exe/Args
|
||||
[[String] [Cmd] [Exe/Args]]
|
||||
[["gcc --version"] [{"gcc", "--version"}] [{"\\"gcc --version\\""}]]
|
||||
]
|
||||
|
||||
When using the overloading variant, a single string will result in a cmd interpretation,
|
||||
several strings will yield a exe-args interpretation. Both version can be set explicitly:
|
||||
|
||||
```
|
||||
system("grep -c false /etc/passwd"); //cmd style
|
||||
system("grep", "-c", "false", "/etc/passwd"); //exe-/args-
|
||||
|
||||
system(cmd="grep -c false /etc/passwd"); //cmd style
|
||||
system(exe="grep", args={"-c", "false", "/etc/passwd"}); //exe-/args-
|
||||
```
|
||||
|
||||
[note If a '"' sign is used in the argument style, it will be passed as part of the argument.
|
||||
If the same effect it wanted with the cmd syntax, it ought to be escaped, i.e. '\\\"'. ]
|
||||
[note The `PATH` variable will automatically be searched in the command style,
|
||||
but the one of the launching process, not the one passed to the child process.]
|
||||
[endsect]
|
||||
|
||||
[section:plat_ext Extensions]
|
||||
|
||||
The simplest form to extend functionality is to provide another handler, which
|
||||
will be called on the respective events on process launching. The names are:
|
||||
|
||||
*`boost::process::on_setup`
|
||||
*`boost::process::on_error`
|
||||
*`boost::process::on_success`
|
||||
|
||||
|
||||
As an example:
|
||||
|
||||
```
|
||||
child c("ls", on_setup([](){cout << "On Setup" << endl;});
|
||||
```
|
||||
|
||||
|
||||
[note On posix all those callbacks will be handled by this process, not the created one.
|
||||
This is different for the posix extensions, which can be executed on the forked process.]
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
52
doc/env.adoc
Normal file
52
doc/env.adoc
Normal file
@@ -0,0 +1,52 @@
|
||||
== Environment
|
||||
|
||||
The `environment` namespace provides all sorts of facilities to query and manipulate the environment of the current process.
|
||||
|
||||
The api should be straight forward, but one oddity that needs to be pointed out is, that environment names
|
||||
are not case sensitive on windows. The key_traits class implements the proper traits depending on the current system.
|
||||
|
||||
Additionally, environment can be lists separated by `:` or `;`; `environment::value` and
|
||||
`environment::value_view` can be used to iterate those.
|
||||
|
||||
Beyond that, the requirements on an environment are a low as possible;
|
||||
an environment is either a list of strings or a list of string-pairs. It is however recommended to use the environment types,
|
||||
as to have the right value comparisons.
|
||||
|
||||
To note is the `find_executable` functions, which searches in an environment for an executable.
|
||||
|
||||
.example/env.cpp:19-28
|
||||
[source,cpp]
|
||||
----
|
||||
include::../example/env.cpp[tag=current_env]
|
||||
----
|
||||
|
||||
== Subprocess environment
|
||||
|
||||
The subprocess environment assignment follows the same constraints:
|
||||
|
||||
.example/env.cpp:34-42
|
||||
[source,cpp,indent=0]
|
||||
----
|
||||
include::../example/env.cpp[tag=subprocess_env]
|
||||
----
|
||||
|
||||
== Inheriting an environment
|
||||
|
||||
The current environment can be obtained by calling `environment::current` which returns
|
||||
a forward range of `environment::key_value_pair_view`.
|
||||
|
||||
.example/env.cpp:48-54
|
||||
[source,cpp,indent=0]
|
||||
----
|
||||
include::../example/env.cpp[tag=vector_env]
|
||||
----
|
||||
|
||||
Alternatively you can use a map container for the environment.
|
||||
|
||||
.example/env.cpp:61-68
|
||||
[source,cpp,indent=0]
|
||||
----
|
||||
include::../example/env.cpp[tag=map_env]
|
||||
----
|
||||
|
||||
|
||||
212
doc/extend.qbk
212
doc/extend.qbk
@@ -1,212 +0,0 @@
|
||||
[def __on_exit__ [globalref boost::process::on_exit on_exit]]
|
||||
[def __on_success__ [globalref boost::process::extend::on_success ex::on_success]]
|
||||
[def __child__ [classref boost::process::child child]]
|
||||
[def __handler__ [classref boost::process::extend::handler handler]]
|
||||
[def __on_success__ [memberref boost::process::extend::handler::on_success on_success]]
|
||||
[def __posix_executor__ [classref boost::process::extend::posix_executor ex::posix_executor]]
|
||||
[def __windows_executor__ [classref boost::process::extend::windows_executor ex::windows_executor]]
|
||||
[def __io_context__ [@http://www.boost.org/doc/libs/release/doc/html/boost_asio/reference/io_context.html boost::asio::io_context]]
|
||||
[def __require_io_context__ [classref boost::process::extend::require_io_context ex::require_io_context]]
|
||||
[def __async_handler__ [classref boost::process::extend::async_handler ex::async_handler]]
|
||||
[def __get_io_context__ [funcref boost::process::extend::get_io_context ex::get_io_context]]
|
||||
|
||||
[section:extend Extensions]
|
||||
To extend the library, the header [headerref boost/process/extend.hpp extend] is provided.
|
||||
|
||||
It only provides the explicit style for custom properties, but no implicit style.
|
||||
|
||||
What this means is, that a custom initializer can be implemented, a reference to which can be passed to one of the launching functions.
|
||||
If a class inherits [classref boost::process::extend::handler] it will be regarded as a initializer and thus directly put into the sequence
|
||||
the executor gets passed.
|
||||
|
||||
[section:structure Structure]
|
||||
|
||||
The executor calls different handlers of the initializers during the process launch.
|
||||
The basic structure is consists of three functions, as given below:
|
||||
|
||||
* [globalref boost::process::extend::on_setup on_setup]
|
||||
* [globalref boost::process::extend::on_error on_error]
|
||||
* [globalref boost::process::extend::on_success on_success]
|
||||
|
||||
'''
|
||||
<imagedata fileref="boost_process/windows_exec.svg"/>
|
||||
'''
|
||||
|
||||
Additionally posix provides three more handlers, listed below:
|
||||
|
||||
* [globalref boost::process::extend::on_fork_error on_fork_error]
|
||||
* [globalref boost::process::extend::on_exec_setup on_exec_setup]
|
||||
* [globalref boost::process::extend::on_exec_error on_exec_error]
|
||||
|
||||
For more information see the reference of [classref boost::process::extend::posix_executor posix_executor].
|
||||
|
||||
[endsect]
|
||||
[section:simple Simple extensions]
|
||||
|
||||
The simplest extension just takes a single handler, which can be done in a functional style.
|
||||
So let's start with a simple hello-world example, while we use a C++14 generic lambda.
|
||||
|
||||
```
|
||||
using namespace boost::process;
|
||||
namespace ex = bp::extend;
|
||||
|
||||
__child__ c("foo", __on_success__=[](auto & exec) {std::cout << "hello world" << std::endl;});
|
||||
```
|
||||
|
||||
Considering that lambda can also capture values, data can easily be shared between handlers.
|
||||
|
||||
To see which members the executor has, refer to [classref boost::process::extend::windows_executor windows_executor]
|
||||
and [classref boost::process::extend::posix_executor posix_executor].
|
||||
|
||||
[note Combined with __on_exit__ this can also handle the process exit.]
|
||||
|
||||
[caution The posix handler symbols are not defined on windows.]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:handler Handler Types]
|
||||
|
||||
Since the previous example is in a functional style, it is not very reusable.
|
||||
To solve that problem, the [classref boost::process::extend::handler handler] has an alias in the `boost::process::extend` namespace, to be inherited.
|
||||
So let's implement the hello world example in a class.
|
||||
|
||||
```
|
||||
struct hello_world : __handler__
|
||||
{
|
||||
template<typename Executor>
|
||||
void __on_success__(Executor & exec) const
|
||||
{
|
||||
std::cout << "hello world" << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
//in our function
|
||||
__child__ c("foo", hello_world());
|
||||
```
|
||||
|
||||
[note The implementation is done via overloading, not overriding.]
|
||||
|
||||
Every handler not implemented dafaults to [classref boost::process::extend::handler handler], where an empty handler is defined for each event.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
|
||||
[section:async Asynchronous Functionality]
|
||||
|
||||
Since `boost.process` provides an interface for [@http://www.boost.org/doc/libs/release/libs/asio/ boost.asio],
|
||||
this functionality is also available for extensions. If the class needs the __io_context__ for some reason, the following code will do that.
|
||||
|
||||
```
|
||||
struct async_foo : __handler__, __require_io_context__
|
||||
{
|
||||
tempalte<typename Executor>
|
||||
void on_setup(Executor & exec)
|
||||
{
|
||||
__io_context__ & ios = __get_io_context__(exec.seq); //gives us a reference and a compiler error if not present.
|
||||
//do something with ios
|
||||
}
|
||||
};
|
||||
```
|
||||
[note Inheriting [globalref boost::process::extend::require_io_context require_io_context] is necessary, so [funcref boost::process::system system] provides one.]
|
||||
|
||||
Additionally the handler can provide a function that is invoked when the child process exits. This is done through __async_handler__.
|
||||
|
||||
[note [globalref boost::process::extend::async_handler async_handler] implies [globalref boost::process::extend::require_io_context require_io_context] .]
|
||||
|
||||
```
|
||||
struct async_bar : __handler, __async_handler__
|
||||
{
|
||||
template<typename Executor>
|
||||
std::function<void(int, const std::error_code&)> on_exit_handler(Executor & exec)
|
||||
{
|
||||
auto handler_ = this->handler;
|
||||
return [handler_](int exit_code, const std::error_code & ec)
|
||||
{
|
||||
std::cout << "hello world, I exited with " << exit_code << std::endl;
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
[caution `on_exit_handler` does not default and is always required when [classref boost::process::extend::async_handler async_handler] is inherited. ]
|
||||
|
||||
[caution `on_exit_handler` uses `boost::asio::signal_set` to listen for SIGCHLD on posix. The application must not also register a signal handler for SIGCHLD using functions such as `signal()` or `sigaction()` (but using `boost::asio::signal_set` is fine). ]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:error Error handling]
|
||||
|
||||
If an error occurs in the initializers it shall be told to the executor and not handles directly. This is because
|
||||
the behaviour can be changed through arguments passed to the launching function. Hence the the executor
|
||||
has the function `set_error`, which takes an [@http://en.cppreference.com/w/cpp/error/error_code std::error_code] and a string.
|
||||
Depending on the cofiguration of the executor, this may either throw, set an internal `error_code`, or do nothing.
|
||||
|
||||
So let's take a simple example, where we set a randomly chosen `error_code`.
|
||||
|
||||
```
|
||||
auto set_error = [](auto & exec)
|
||||
{
|
||||
std::error_code ec{42, std::system_category()};
|
||||
exec.set_error(ec, "a fake error");
|
||||
|
||||
};
|
||||
__child__ c("foo", on_setup=set_error);
|
||||
```
|
||||
|
||||
Since we do not specify the error-handling mode in this example, this will throw [classref boost::process::process_error process_error].
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:exec_over Executor Overloading]
|
||||
|
||||
Now that we have a custom initializer, let's consider how we can handle differences between different executors.
|
||||
The distinction is between posix and windows and `char` and `wchar_t` on windows.
|
||||
One solution is to use the [@http://www.boost.org/doc/libs/master/boost/system/api_config.hpp BOOST_WINDOWS_API and BOOST_POSIX_API] macros,
|
||||
which are automatically available as soon as any process-header is included.
|
||||
|
||||
Another variant are the type aliases __posix_executor__ and __windows_executor__, where the executor, not on the current system is a forward-declaration.
|
||||
This works fine, because the function will never get invoked. So let's implement another example, which prints the executable name __on_success__.
|
||||
|
||||
```
|
||||
struct hello_exe : __handler__
|
||||
{
|
||||
template<typename Sequence>
|
||||
void __on_success__(__posix_executor__<Sequence> & exec)
|
||||
{
|
||||
std::cout << "posix-exe: " << exec.exe << std::endl;
|
||||
}
|
||||
|
||||
template<typename Sequence>
|
||||
void __on_success__(__windows_executor__<char, Sequence> & exec)
|
||||
{
|
||||
//note: exe might be a nullptr on windows.
|
||||
if (exec.exe != nullptr)
|
||||
std::cout << "windows-exe: " << exec.exe << std::endl;
|
||||
else
|
||||
std::cout << "windows didn't use exe" << std::endl;
|
||||
}
|
||||
|
||||
template<typename Sequence>
|
||||
void __on_success__(__windows_executor__<wchar_t, Sequence> & exec)
|
||||
{
|
||||
//note: exe might be a nullptr on windows.
|
||||
if (exec.exe != nullptr)
|
||||
std::wcout << L"windows-exe: " << exec.exe << std::endl;
|
||||
else
|
||||
std::cout << "windows didn't use exe" << std::endl;
|
||||
}
|
||||
|
||||
};
|
||||
```
|
||||
|
||||
So given our example, the definitions with the non-native exectur are still a template so that they will not be evaluated if not used. Hence this provides a
|
||||
way to implement systems-specific code without using the preprocessor.
|
||||
|
||||
[note If you only write a partial implementation, e.g. only for __posix_executor__, the other variants will default to __handler__].
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
87
doc/faq.qbk
87
doc/faq.qbk
@@ -1,87 +0,0 @@
|
||||
[section:faq Frequently Asked Questions]
|
||||
|
||||
[section:dead_lock Why does this produce a deadlock?]
|
||||
|
||||
Now let's revisit our c++filt example and we will put in an obvious mistake.
|
||||
This might however be not as obvious for more complex applications.
|
||||
|
||||
```
|
||||
vector<string> demangle(vector<string> in)
|
||||
{
|
||||
|
||||
ipstream is;
|
||||
opstream os;
|
||||
child c("c++filt", std_out > is, std_in < os);
|
||||
|
||||
vector<string> data;
|
||||
for (auto & elem : data)
|
||||
{
|
||||
string line;
|
||||
getline(is, line);
|
||||
os << elem;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
We switched the read and write operation up, so that's causing a dead-lock.
|
||||
This locks immediately. This is because `c++filt` expects input, before
|
||||
outputting any data. The launching process on the other hand waits for its output.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:closep Why does the pipe not close?]
|
||||
|
||||
Now for another example, which might look correct, let's consider you want
|
||||
to use `ls` to read the current directory.
|
||||
|
||||
```
|
||||
ipstream is;
|
||||
child c("ls", std_out > is);
|
||||
|
||||
std::string file;
|
||||
while (is >> file)
|
||||
cout << "File: " << file << endl;
|
||||
|
||||
```
|
||||
|
||||
This will also deadlock, because the pipe does not close when the subprocess exits.
|
||||
So the `ipstream` will still look for data even though the process has ended.
|
||||
|
||||
[note It is not possible to use automatically pipe-closing in this library, because
|
||||
a pipe might be a file-handle (as for async pipes on windows).]
|
||||
|
||||
But, since pipes are buffered, you might get incomplete data if you do this:
|
||||
|
||||
```
|
||||
ipstream is;
|
||||
child c("ls", std_out > is);
|
||||
|
||||
std::string file;
|
||||
while (c.running())
|
||||
{
|
||||
is >> file;
|
||||
cout << "File: " << file << endl;
|
||||
}
|
||||
```
|
||||
|
||||
It is therefore highly recommended that you use the asynchronous api if you are
|
||||
not absolutely sure how the output will look.
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:wchar_t When will the codecvt be used?]
|
||||
|
||||
Since windows does not use UTF-8 it is sometimes unavoidable to use the `wchar_t` version of the WinApi.
|
||||
To keep this library consistent it provides `wchar_t` support on posix also.
|
||||
|
||||
Since the posix api is purely `char` every `wchar_t` based type will be converted into `char`.
|
||||
|
||||
Windows on the other hand is more selective; the default is to use `char`,
|
||||
but if any parameter requires `wchar_t`, everything will be converted to `wchar_t`.
|
||||
This also includes `boost::filesystem::path`. Additionally, if the system does not provide
|
||||
the `char` api (as is the case with Windows CE) everything will also be converted.
|
||||
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
51
doc/index.adoc
Normal file
51
doc/index.adoc
Normal file
@@ -0,0 +1,51 @@
|
||||
= boost.process
|
||||
Klemens Morgenstern <klemens.morgenstern@gmx.net>
|
||||
Version 2.0, 19.11.2024
|
||||
:source-highlighter: rouge
|
||||
:toc: left
|
||||
:toclevels: 4
|
||||
:icons: font
|
||||
:idprefix:
|
||||
:docinfo: private-footer
|
||||
:source-highlighter: rouge
|
||||
:source-language: c++
|
||||
:example-caption: Example
|
||||
|
||||
:imagesdir: ./images
|
||||
|
||||
:leveloffset: +1
|
||||
|
||||
include::quickstart.adoc[]
|
||||
include::launcher.adoc[]
|
||||
|
||||
= Initializers
|
||||
|
||||
include::start_dir.adoc[]
|
||||
include::stdio.adoc[]
|
||||
include::env.adoc[]
|
||||
|
||||
= Reference
|
||||
|
||||
|
||||
include::reference/bind_launcher.adoc[]
|
||||
include::reference/cstring_ref.adoc[]
|
||||
include::reference/default_launcher.adoc[]
|
||||
include::reference/environment.adoc[]
|
||||
include::reference/error.adoc[]
|
||||
include::reference/execute.adoc[]
|
||||
include::reference/exit_code.adoc[]
|
||||
include::reference/ext.adoc[]
|
||||
include::reference/pid.adoc[]
|
||||
include::reference/popen.adoc[]
|
||||
include::reference/process.adoc[]
|
||||
include::reference/process_handle.adoc[]
|
||||
include::reference/shell.adoc[]
|
||||
include::reference/start_dir.adoc[]
|
||||
include::reference/stdio.adoc[]
|
||||
include::reference/ext.adoc[]
|
||||
include::reference/posix/bind_fd.adoc[]
|
||||
include::reference/windows/creation_flags.adoc[]
|
||||
include::reference/windows/show_window.adoc[]
|
||||
|
||||
include::version2.adoc[]
|
||||
include::acknowledgements.adoc[]
|
||||
@@ -1,24 +0,0 @@
|
||||
[section:introduction Introduction]
|
||||
|
||||
Boost.Process is a library to manage system processes. It can be used to:
|
||||
|
||||
* create child processes
|
||||
* setup streams for child processes
|
||||
* communicate with child processes through streams (synchronously or asynchronously)
|
||||
* wait for processes to exit (synchronously or asynchronously)
|
||||
* terminate processes
|
||||
|
||||
Here's a simple example of how to start a program with Boost.Process:
|
||||
|
||||
[def ipstream [classref boost::process::ipstream ipstream]]
|
||||
[def system [funcref boost::process::system system]]
|
||||
[def std_out [globalref boost::process::std_out std_out]]
|
||||
[def child [globalref boost::process::child child]]
|
||||
[def boost/process.hpp [headerref boost/process.hpp boost/process.hpp]]
|
||||
[def std::string [@http://en.cppreference.com/w/cpp/string/basic_string std::string]]
|
||||
[def std::getline [@http://en.cppreference.com/w/cpp/string/basic_string/getline std::getline]]
|
||||
|
||||
[import ../example/intro.cpp]
|
||||
[intro]
|
||||
|
||||
[endsect]
|
||||
126
doc/launcher.adoc
Normal file
126
doc/launcher.adoc
Normal file
@@ -0,0 +1,126 @@
|
||||
= Launcher
|
||||
|
||||
The process creation is done by a process_launcher.
|
||||
The constructor of `process` will use the default_launcher, which varies by system.
|
||||
There are additional launcher available on most systems.
|
||||
|
||||
[cols="1,1,1,1"]
|
||||
|===
|
||||
|Name | Summary | Default on | Available on
|
||||
|
||||
|
||||
|
||||
|
||||
|`windows::default_launcher` | `CreateProcessW` | windows |windows
|
||||
|`windows::as_user_launcher` | `CreateProcessAsUserW` | |windows
|
||||
|`windows::with_logon_launcher` | `CreateProcessWithLogonW` | |windows
|
||||
|`windows::with_token_launcher` | `CreateProcessWithTokenW` | |windows
|
||||
|`posix::default_launcher` | fork & an error pipe | most of posix |posix
|
||||
|`posix::fork_and_forget` | fork without error pipe | |posix
|
||||
|`posix::vfork_launcher` | vfork | |posix
|
||||
|===
|
||||
|
||||
A launcher is invoked through the call operator.
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
auto l = windows::as_user_launcher((HANDLE)0xDEADBEEF);
|
||||
asio::io_context ctx;
|
||||
boost::system::error_code ec;
|
||||
auto proc = l(ctx, ec, "C:\\User\\boost\\Downloads\\totally_not_a_virus.exe", {});
|
||||
----
|
||||
|
||||
The launcher will call certain functions on the initializer if they're present, as documented below.
|
||||
The initializer are used to modify the process behaviour.
|
||||
|
||||
|
||||
== Linux Launchers
|
||||
|
||||
The default launchers on linux open an internal pipe to communicate errors that occur after forking back to the parent process.
|
||||
|
||||
NOTE: A pipe can be used if one end is open on the parent, the other on the child.
|
||||
This allows the parents to select on his pipe-end to know if the child exited.
|
||||
|
||||
This can be prevented by using the `fork_and_forget_launcher`.
|
||||
Alternatively, the `vfork_launcher` can report errors directly back to the parent process.
|
||||
|
||||
Thus some calls to the initializers occur after forking from the child process.
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
struct custom_initializer
|
||||
{
|
||||
// called before a call to fork. A returned error will cancel the launch.
|
||||
template<typename Launcher>
|
||||
error_code on_setup(Launcher & launcher, const filesystem::path &executable, const char * const * (&cmd_line));
|
||||
|
||||
// called for every initializer if an error occurred during setup or process creation
|
||||
template<typename Launcher>
|
||||
void on_error(Launcher & launcher, const filesystem::path &executable, const char * const * (&cmd_line),
|
||||
const error_code & ec);
|
||||
|
||||
// called after successful process creation
|
||||
template<typename Launcher>
|
||||
void on_success(Launcher & launcher, const filesystem::path &executable, const char * const * (&cmd_line));
|
||||
|
||||
// called for every initializer if an error occurred when forking, in addition to on_error.
|
||||
template<typename Launcher>
|
||||
void on_fork_error(Launcher & launcher, const filesystem::path &executable, const char * const * (&cmd_line),
|
||||
const error_code & ec);
|
||||
|
||||
|
||||
// called before a call to execve. A returned error will cancel the launch. Called from the child process.
|
||||
template<typename Launcher>
|
||||
error_code on_exec_setup(Launcher & launcher, const filesystem::path &executable, const char * const * (&cmd_line));
|
||||
|
||||
|
||||
// called after a failed call to execve from the child process.
|
||||
template<typename Launcher>
|
||||
void on_exec_error(Launcher & launcher, const filesystem::path &executable, const char * const * (&cmd_line));
|
||||
};
|
||||
----
|
||||
|
||||
The call sequence on success:
|
||||
|
||||
image::posix_success.svg[]
|
||||
|
||||
The call sequence when fork fails:
|
||||
|
||||
image::posix_fork_err.svg[]
|
||||
|
||||
The call sequence when exec fails:
|
||||
|
||||
image::posix_exec_err.svg[]
|
||||
|
||||
The launcher will close all non-whitelisted file descriptors after `on_exec_setup`.
|
||||
|
||||
== Windows Launchers
|
||||
|
||||
Windows launchers are pretty straight forward, they will call the following functions on the initializer if present.
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
struct custom_initializer
|
||||
{
|
||||
// called before a call to CreateProcess. A returned error will cancel the launch.
|
||||
template<typename Launcher>
|
||||
error_code on_setup(Launcher & launcher, const filesystem::path &executable, std::wstring &cmd_line);
|
||||
|
||||
// called for every initializer if an error occurred during setup or process creation
|
||||
template<typename Launcher>
|
||||
void on_error(Launcher & launcher, const filesystem::path &executable, std::wstring &cmd_line,
|
||||
const error_code & ec);
|
||||
|
||||
// called after successful process creation
|
||||
template<typename Launcher>
|
||||
void on_success(Launcher & launcher, const filesystem::path &executable, std::wstring &cmd_line);
|
||||
|
||||
};
|
||||
----
|
||||
|
||||
NOTE: All the additional launchers for windows inherit `default_launcher`.
|
||||
|
||||
The call sequence is as follows:
|
||||
|
||||
image::windows_exec.svg
|
||||
'''
|
||||
@@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" standalone="yes"?>
|
||||
<programlisting>
|
||||
for (auto & s : seq)
|
||||
s.<methodname alt="boost::process::extend::handler::on_setup">on_setup</methodname>(*this);
|
||||
|
||||
if (<methodname alt="boost::process::extend::posix_executor::error">error</methodname>())
|
||||
{
|
||||
for (auto & s : seq)
|
||||
s.<methodname alt="boost::process::extend::handler::on_error">on_error</methodname>(*this, <methodname alt="boost::process::extend::posix_executor::error">error</methodname>());
|
||||
return <classname alt="boost::process::child">child</classname>();
|
||||
}
|
||||
|
||||
pid = <ulink url="http://pubs.opengroup.org/onlinepubs/009695399/functions/fork.html">fork()</ulink>
|
||||
<methodname alt="boost::process::extend::handler::on_setup">on_setup</methodname>(*this);
|
||||
|
||||
if (pid == -1) //fork error
|
||||
{
|
||||
<methodname alt="boost::process::extend::posix_executor::set_error">set_error</methodname>(<functionname alt="boost::process::extend::get_last_error">get_last_error</functionname>());
|
||||
for (auto & s : seq)
|
||||
s.<methodname alt="boost::process::extend::handler::on_fork_error">on_fork_error</methodname>(*this, <methodname alt="boost::process::extend::posix_executor::error">error</methodname>());
|
||||
for (auto & s : seq)
|
||||
s.<methodname alt="boost::process::extend::handler::on_error">on_error</methodname>(*this, <methodname alt="boost::process::extend::posix_executor::error">error</methodname>());
|
||||
return <classname alt="boost::process::child">child</classname>()
|
||||
}
|
||||
else if (pid == 0) //child process
|
||||
{
|
||||
for (auto & s : seq)
|
||||
s.<methodname alt="boost::process::extend::handler::on_exec_setup">on_exec_setup</methodname>(*this);
|
||||
<ulink url="http://pubs.opengroup.org/onlinepubs/009695399/functions/exec.html">execve</ulink>(exe, cmd_line, env);
|
||||
auto ec = <functionname alt="boost::process::extend::get_last_error">get_last_error</functionname>();
|
||||
for (auto & s : seq)
|
||||
s.<methodname alt="boost::process::extend::handler::on_exec_error">on_exec_error</methodname>(*this);
|
||||
|
||||
<emphasis>unspecified();</emphasis>//here the error is send to the father process interally
|
||||
|
||||
<ulink url="http://en.cppreference.com/w/cpp/utility/program/exit">std::exit</ulink>(<ulink url="http://en.cppreference.com/w/c/program/EXIT_status">EXIT_FAILURE</ulink>);
|
||||
return <classname alt="boost::process::child">child</classname>(); //for C++ compliance
|
||||
}
|
||||
|
||||
<classname alt="boost::process::child">child</classname> c(pid, exit_code);
|
||||
|
||||
<emphasis>unspecified();</emphasis>//here, we read the the error from the child process
|
||||
|
||||
if (<methodname alt="boost::process::extend::posix_executor::error">error</methodname>())
|
||||
for (auto & s : seq)
|
||||
s.<methodname alt="boost::process::extend::handler::on_error">on_error</methodname>(*this, <methodname alt="boost::process::extend::posix_executor::error">error</methodname>());
|
||||
else
|
||||
for (auto & s : seq)
|
||||
s.<methodname alt="boost::process::extend::handler::on_error">on_success</methodname>(*this);
|
||||
|
||||
//now we check again, because a on_success handler might've errored.
|
||||
if (<methodname alt="boost::process::extend::posix_executor::error">error</methodname>())
|
||||
{
|
||||
for (auto & s : seq)
|
||||
s.<methodname alt="boost::process::extend::handler::on_error">on_error</methodname>(*this, <methodname alt="boost::process::extend::posix_executor::error">error</methodname>());
|
||||
return <classname alt="boost::process::child">child</classname>();
|
||||
}
|
||||
else
|
||||
return c;
|
||||
</programlisting>
|
||||
@@ -1,21 +0,0 @@
|
||||
[library Boost.Process
|
||||
[quickbook 1.5]
|
||||
[authors [Morgenstern, Klemens David]]
|
||||
[copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 Julio M. Merino Vidal, Ilya Sokolov, Felipe Tanus, Jeff Flinn, Boris Schaeling, 2016 Klemens D. Morgenstern]
|
||||
[id process]
|
||||
[dirname process]
|
||||
[license
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
]
|
||||
]
|
||||
|
||||
[include introduction.qbk]
|
||||
[include concepts.qbk]
|
||||
[include tutorial.qbk]
|
||||
[include design.qbk]
|
||||
[include extend.qbk]
|
||||
[include faq.qbk]
|
||||
[xinclude autodoc.xml]
|
||||
[include acknowledgements.qbk]
|
||||
104
doc/quickstart.adoc
Normal file
104
doc/quickstart.adoc
Normal file
@@ -0,0 +1,104 @@
|
||||
= Quickstart
|
||||
|
||||
A process needs four things to be launched:
|
||||
|
||||
* an asio execution_context / executor
|
||||
* a path to an executable
|
||||
* a list of arguments
|
||||
* a variadic set of initializers
|
||||
|
||||
.example/quickstart.cpp:13-17
|
||||
[source,cpp,indent=0]
|
||||
----
|
||||
include::../example/quickstart.cpp[tag=cp]
|
||||
----
|
||||
<1> The executor for the process handle
|
||||
<2> The Path to the executable
|
||||
<3> The argument list in the form of an `std::initializer_list`.
|
||||
<4> Not additional initializers
|
||||
|
||||
The started process can then be awaited or terminated.
|
||||
|
||||
== Lifetime
|
||||
|
||||
If the process handle goes out of scope, it will terminate the subprocess.
|
||||
You can prevent this, by calling `proc.detach()`; do however note that this
|
||||
can lead to zombie processes.
|
||||
|
||||
A process that completed will deliver an exit-code,
|
||||
which can be obtained by calling `.exit_code` on the exited process and which is
|
||||
also returned from `.wait()`.
|
||||
|
||||
.example/quickstart.cpp:22-23
|
||||
[source,cpp, indent=0]
|
||||
----
|
||||
include::../example/quickstart.cpp[tag=ls]
|
||||
----
|
||||
|
||||
The normal exit-code is what the subprocess returned from `main`;
|
||||
posix will however add additional information about the process.
|
||||
This is called the `native_exit_code`.
|
||||
|
||||
|
||||
The `.running()` function can be used to detect if the process is still active.
|
||||
|
||||
|
||||
== Signalling the subprocess
|
||||
|
||||
The parent process can signal the subprocess demanding certain actions.
|
||||
|
||||
`.terminate` will cause the subprocess to exit immediately (`SIGKILL` on posix).
|
||||
This is the only reliable & portable way to end a subprocess.
|
||||
|
||||
.example/quickstart.cpp:28-29
|
||||
[source,cpp,indent=0]
|
||||
----
|
||||
include::../example/quickstart.cpp[tag=terminate]
|
||||
----
|
||||
|
||||
`.request_exit` will ask the subprocess to shutdown (`SIGTERM` on posix),
|
||||
which the subprocess might ignore.
|
||||
|
||||
.example/quickstart.cpp:34-36
|
||||
[source,cpp]
|
||||
----
|
||||
include::../example/quickstart.cpp[tag=request_exit]
|
||||
----
|
||||
|
||||
`.interrupt` will send an SIGINT to the subprocess, which a subprocess might
|
||||
interpret as a signal for shutdown.
|
||||
|
||||
WARNING: interrupt requires the initializer `windows::create_new_process_group` to be set on windows
|
||||
|
||||
.example/quickstart.cpp:41-43
|
||||
[source,cpp]
|
||||
----
|
||||
include::../example/quickstart.cpp[tag=interrupt]
|
||||
----
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:execute Execute functions]
|
||||
|
||||
Process v2 provides `execute` and `async_execute` functions that can be used for managed executions.
|
||||
|
||||
.example/quickstart.cpp:48
|
||||
[source,cpp]
|
||||
----
|
||||
include::../example/quickstart.cpp[tag=execute]
|
||||
----
|
||||
|
||||
The async version supports cancellation and will forward cancellation types as follows:
|
||||
|
||||
- `asio::cancellation_type::total` -> interrupt
|
||||
- `asio::cancellation_type::partial` -> request_exit
|
||||
- `asio::cancellation_type::terminal` -> terminate
|
||||
|
||||
.example/quickstart.cpp:53-56
|
||||
[source,cpp]
|
||||
----
|
||||
include::../example/quickstart.cpp[tag=async_execute]
|
||||
----
|
||||
<1> After 10 seconds send a request_exit.
|
||||
<2> After 20 seconds terminate
|
||||
|
||||
16
doc/reference/bind_launcher.adoc
Normal file
16
doc/reference/bind_launcher.adoc
Normal file
@@ -0,0 +1,16 @@
|
||||
== `bind_launcher.hpp`
|
||||
|
||||
The `bind_launcher` utilities allow on the fly construction of a launcher with bound initializers.
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
// Creates a new launcher with the bound initializer.
|
||||
template<typename Launcher, typename ... Init>
|
||||
auto bind_launcher(Launcher && launcher, Init && ... init);
|
||||
|
||||
// Calls bind_launcher with the default_launcher as the first parameter.
|
||||
// The new launcher with bound parameters
|
||||
template<typename ... Init>
|
||||
auto bind_default_launcher(Init && ... init);
|
||||
----
|
||||
|
||||
3
doc/reference/cstring_ref.adoc
Normal file
3
doc/reference/cstring_ref.adoc
Normal file
@@ -0,0 +1,3 @@
|
||||
== `cstring_ref.hpp`
|
||||
|
||||
The `cstring_ref` is a string-view like type that holds a null-terminated string.
|
||||
22
doc/reference/default_launcher.adoc
Normal file
22
doc/reference/default_launcher.adoc
Normal file
@@ -0,0 +1,22 @@
|
||||
== `default_launcher.hpp`
|
||||
[#default_launcher]
|
||||
|
||||
The `default_launcher` is the standard way of creating a process.
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
asio::io_context ctx;
|
||||
process proc(ctx.get_executor(), "test", {});
|
||||
// equivalent to
|
||||
process proc = default_launcher()(ctx.get_executor(), "test", {});
|
||||
----
|
||||
|
||||
It has four overloads:
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
(ExecutionContext &, filesystem::path, Args && args, Inits && ... inits) -> basic_process<typename ExecutionContext::executor_type>
|
||||
(Executor &, filesystem::path, Args && args, Inits && ... inits) -> basic_process<Executor>;
|
||||
(ExecutionContext &, error_code&, filesystem::path, Args && args, Inits && ... inits) -> basic_process<typename ExecutionContext::executor_type>;`
|
||||
(Executor &, error_code&, filesystem::path, Args && args, Inits && ... inits) -> basic_process<Executor>
|
||||
----
|
||||
735
doc/reference/environment.adoc
Normal file
735
doc/reference/environment.adoc
Normal file
@@ -0,0 +1,735 @@
|
||||
== `environment.hpp`
|
||||
[#environment]
|
||||
|
||||
=== `environment`
|
||||
|
||||
The `environment` header provides facilities to manipulate the current environment and set it for new processes.
|
||||
|
||||
|
||||
An environment is a a `range` of `T` fulfilling these requirements:
|
||||
|
||||
For `T value`
|
||||
* - std::get<0>(value) must return a type comparable to `key_view`.
|
||||
* - std::get<1>(value) must return a type convertible to `value_view`.
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
|
||||
// Namespace for information and functions regarding the calling process.
|
||||
namespace environment
|
||||
{
|
||||
|
||||
// A char traits type that reflects the OS rules for string representing environment keys.
|
||||
/* Can be an alias of std::char_traits. May only be defined for `char` and `wchar_t`.
|
||||
*
|
||||
* Windows treats keys as case-insensitive yet preserving. The char traits are made to reflect
|
||||
* that behaviour.
|
||||
*/
|
||||
template<typename Char>
|
||||
using key_char_traits = implementation_defined ;
|
||||
|
||||
// A char traits type that reflects the OS rules for string representing environment values.
|
||||
/* Can be an alias of std::char_traits. May only be defined for `char` and `wchar_t`.
|
||||
*/
|
||||
template<typename Char>
|
||||
using value_char_traits = implementation_defined ;
|
||||
|
||||
// The character type used by the environment. Either `char` or `wchar_t`.
|
||||
using char_type = implementation_defined ;
|
||||
|
||||
// The equal character in an environment string used to separate key and value.
|
||||
constexpr char_type equality_sign = implementation_defined;
|
||||
|
||||
// The delimiter in environemtn lists. Commonly used by the `PATH` variable.
|
||||
constexpr char_type delimiter = implementation_defined;
|
||||
|
||||
// The native handle of an environment. Note that this can be an owning pointer and is generally not thread safe.
|
||||
using native_handle = implementation_defined;
|
||||
|
||||
|
||||
// A forward iterator over string_view used by a value or value_view to iterator through environments that are lists.
|
||||
struct value_iterator;
|
||||
|
||||
// A view type for a key of an environment
|
||||
struct key_view
|
||||
{
|
||||
using value_type = char_type;
|
||||
using traits_type = key_char_traits<char_type>;
|
||||
using string_view_type = basic_string_view<char_type, traits_type>;
|
||||
using string_type = std::basic_string<char_type, key_char_traits<char_type>>;
|
||||
|
||||
key_view() noexcept = default;
|
||||
key_view( const key_view& p ) = default;
|
||||
key_view( key_view&& p ) noexcept = default;
|
||||
template<typename Source>
|
||||
key_view( const Source& source );
|
||||
key_view( const char_type * p);
|
||||
key_view( char_type * p);
|
||||
|
||||
~key_view() = default;
|
||||
|
||||
key_view& operator=( const key_view& p ) = default;
|
||||
key_view& operator=( key_view&& p ) noexcept = default;
|
||||
key_view& operator=( string_view_type source );
|
||||
|
||||
void swap( key_view& other ) noexcept;
|
||||
|
||||
string_view_type native() const noexcept;
|
||||
|
||||
operator string_view_type() const;
|
||||
|
||||
int compare( const key_view& p ) const noexcept;
|
||||
int compare( string_view_type str ) const;
|
||||
int compare( const value_type* s ) const;
|
||||
|
||||
template< class CharT, class Traits = std::char_traits<CharT>,
|
||||
class Alloc = std::allocator<CharT> >
|
||||
std::basic_string<CharT,Traits,Alloc>
|
||||
basic_string( const Alloc& alloc = Alloc()) const;
|
||||
|
||||
std::string string() const;
|
||||
std::wstring wstring() const;
|
||||
|
||||
string_type native_string() const;
|
||||
|
||||
friend bool operator==(key_view l, key_view r);
|
||||
friend bool operator!=(key_view l, key_view r);
|
||||
friend bool operator<=(key_view l, key_view r);
|
||||
friend bool operator>=(key_view l, key_view r);
|
||||
friend bool operator< (key_view l, key_view r);
|
||||
friend bool operator> (key_view l, key_view r);
|
||||
|
||||
bool empty() const;
|
||||
|
||||
template< class CharT, class Traits >
|
||||
friend std::basic_ostream<CharT,Traits>&
|
||||
operator<<( std::basic_ostream<CharT,Traits>& os, const key_view& p );
|
||||
|
||||
template< class CharT, class Traits >
|
||||
friend std::basic_istream<CharT,Traits>&
|
||||
operator>>( std::basic_istream<CharT,Traits>& is, key_view& p );
|
||||
|
||||
const value_type * data() const;
|
||||
std::size_t size() const;
|
||||
};
|
||||
|
||||
// A view for a value in an environment
|
||||
struct value_view
|
||||
{
|
||||
using value_type = char_type;
|
||||
using string_view_type = basic_cstring_ref<char_type, value_char_traits<char_type>>;
|
||||
using string_type = std::basic_string<char_type, value_char_traits<char_type>>;
|
||||
using traits_type = value_char_traits<char_type>;
|
||||
|
||||
value_view() noexcept = default;
|
||||
value_view( const value_view& p ) = default;
|
||||
value_view( value_view&& p ) noexcept = default;
|
||||
template<typename Source>
|
||||
value_view( const Source& source );
|
||||
value_view( const char_type * p);
|
||||
value_view( char_type * p);
|
||||
|
||||
~value_view() = default;
|
||||
|
||||
value_view& operator=( const value_view& p ) = default;
|
||||
value_view& operator=( value_view&& p ) noexcept = default;
|
||||
value_view& operator=( string_view_type source );
|
||||
|
||||
void swap( value_view& other ) noexcept;
|
||||
|
||||
string_view_type native() const noexcept ;
|
||||
|
||||
operator string_view_type() const;
|
||||
operator typename string_view_type::string_view_type() const;
|
||||
|
||||
int compare( const value_view& p ) const noexcept;
|
||||
int compare( string_view_type str ) const;
|
||||
int compare( const value_type* s ) const;
|
||||
|
||||
template< class CharT, class Traits = std::char_traits<CharT>,
|
||||
class Alloc = std::allocator<CharT> >
|
||||
std::basic_string<CharT,Traits,Alloc>
|
||||
basic_string( const Alloc& alloc = Alloc() ) const;
|
||||
std::string string() const;
|
||||
std::wstring wstring() const;
|
||||
|
||||
string_type native_string() const;
|
||||
bool empty() const;
|
||||
|
||||
friend bool operator==(value_view l, value_view r);
|
||||
friend bool operator!=(value_view l, value_view r);
|
||||
friend bool operator<=(value_view l, value_view r);
|
||||
friend bool operator>=(value_view l, value_view r);
|
||||
friend bool operator< (value_view l, value_view r);
|
||||
friend bool operator> (value_view l, value_view r);
|
||||
|
||||
|
||||
template< class CharT, class Traits >
|
||||
friend std::basic_ostream<CharT,Traits>&
|
||||
operator<<( std::basic_ostream<CharT,Traits>& os, const value_view& p );
|
||||
|
||||
template< class CharT, class Traits >
|
||||
friend std::basic_istream<CharT,Traits>&
|
||||
operator>>( std::basic_istream<CharT,Traits>& is, value_view& p );
|
||||
value_iterator begin() const;
|
||||
value_iterator end() const;
|
||||
|
||||
const char_type * c_str();
|
||||
const value_type * data() const;
|
||||
std::size_t size() const;
|
||||
};
|
||||
|
||||
// A view for a key value pair in an environment
|
||||
struct key_value_pair_view
|
||||
{
|
||||
using value_type = char_type;
|
||||
using string_type = std::basic_string<char_type>;
|
||||
using string_view_type = basic_cstring_ref<char_type>;
|
||||
using traits_type = std::char_traits<char_type>;
|
||||
|
||||
key_value_pair_view() noexcept = default;
|
||||
key_value_pair_view( const key_value_pair_view& p ) = default;
|
||||
key_value_pair_view( key_value_pair_view&& p ) noexcept = default;
|
||||
template<typename Source,
|
||||
typename = typename std::enable_if<is_constructible<string_view_type, Source>::value>::type>
|
||||
key_value_pair_view( const Source& source );
|
||||
|
||||
key_value_pair_view( const char_type * p);
|
||||
key_value_pair_view( char_type * p);
|
||||
|
||||
|
||||
~key_value_pair_view() = default;
|
||||
|
||||
key_value_pair_view& operator=( const key_value_pair_view& p ) = default;
|
||||
key_value_pair_view& operator=( key_value_pair_view&& p ) noexcept = default;
|
||||
|
||||
void swap( key_value_pair_view& other ) noexcept;
|
||||
|
||||
string_view_type native() const noexcept;
|
||||
|
||||
operator string_view_type() const;
|
||||
operator typename string_view_type::string_view_type() const;
|
||||
|
||||
int compare( key_value_pair_view p ) const noexcept;
|
||||
int compare( const string_type& str ) const;
|
||||
int compare( string_view_type str ) const;
|
||||
int compare( const value_type* s ) const;
|
||||
|
||||
template< class CharT, class Traits = std::char_traits<CharT>, class Alloc = std::allocator<CharT> >
|
||||
std::basic_string<CharT,Traits,Alloc>
|
||||
basic_string( const Alloc& alloc = Alloc()) const;
|
||||
std::string string() const;
|
||||
std::wstring wstring() const;
|
||||
|
||||
string_type native_string() const;
|
||||
|
||||
bool empty() const;
|
||||
|
||||
key_view key() const;
|
||||
value_view value() const;
|
||||
|
||||
friend bool operator==(key_value_pair_view l, key_value_pair_view r);
|
||||
friend bool operator!=(key_value_pair_view l, key_value_pair_view r);
|
||||
friend bool operator<=(key_value_pair_view l, key_value_pair_view r);
|
||||
friend bool operator>=(key_value_pair_view l, key_value_pair_view r);
|
||||
friend bool operator< (key_value_pair_view l, key_value_pair_view r);
|
||||
friend bool operator> (key_value_pair_view l, key_value_pair_view r);
|
||||
|
||||
|
||||
template< class CharT, class Traits >
|
||||
friend std::basic_ostream<CharT,Traits>&
|
||||
operator<<( std::basic_ostream<CharT,Traits>& os, const key_value_pair_view& p );
|
||||
|
||||
template< class CharT, class Traits >
|
||||
friend std::basic_istream<CharT,Traits>&
|
||||
operator>>( std::basic_istream<CharT,Traits>& is, key_value_pair_view& p );
|
||||
|
||||
template<std::size_t Idx>
|
||||
inline auto get() const -> typename conditional<Idx == 0u, key_view,
|
||||
value_view>::type;
|
||||
const value_type * c_str() const noexcept;
|
||||
const value_type * data() const;
|
||||
std::size_t size() const;
|
||||
|
||||
};
|
||||
|
||||
// Allow tuple-likg getters & structured bindings.
|
||||
template<> key_view key_value_pair_view::get<0u>() const;
|
||||
template<> value_view key_value_pair_view::get<1u>() const;
|
||||
|
||||
// A class representing a key within an environment.
|
||||
struct key
|
||||
{
|
||||
using value_type = char_type;
|
||||
using traits_type = key_char_traits<char_type>;
|
||||
using string_type = std::basic_string<char_type, traits_type>;
|
||||
using string_view_type = basic_string_view<char_type, traits_type>;
|
||||
|
||||
key();
|
||||
key( const key& p ) = default;
|
||||
key( key&& p ) noexcept = default;
|
||||
key( const string_type& source );
|
||||
key( string_type&& source );
|
||||
key( const value_type * raw );
|
||||
key( value_type * raw );
|
||||
|
||||
explicit key(key_view kv);
|
||||
|
||||
|
||||
template< class Source >
|
||||
key( const Source& source);
|
||||
|
||||
key(const typename conditional<is_same<value_type, char>::value, wchar_t, char>::type * raw);
|
||||
|
||||
template< class InputIt >
|
||||
key( InputIt first, InputIt last);
|
||||
|
||||
~key() = default;
|
||||
|
||||
key& operator=( const key& p ) = default;
|
||||
key& operator=( key&& p );
|
||||
key& operator=( string_type&& source );
|
||||
|
||||
template< class Source >
|
||||
key& operator=( const Source& source );
|
||||
|
||||
key& assign( string_type&& source );
|
||||
|
||||
template< class Source >
|
||||
key& assign( const Source& source );
|
||||
template< class InputIt >
|
||||
key& assign( InputIt first, InputIt last );
|
||||
|
||||
void clear();
|
||||
|
||||
void swap( key& other ) noexcept;
|
||||
|
||||
const value_type* c_str() const noexcept;
|
||||
const string_type& native() const noexcept;
|
||||
string_view_type native_view() const noexcept;
|
||||
|
||||
operator string_type() const;
|
||||
operator string_view_type() const;
|
||||
|
||||
int compare( const key& p ) const noexcept;
|
||||
int compare( const string_type& str ) const;
|
||||
int compare( string_view_type str ) const;
|
||||
int compare( const value_type* s ) const;
|
||||
|
||||
template< class CharT, class Traits = std::char_traits<CharT>,
|
||||
class Alloc = std::allocator<CharT> >
|
||||
std::basic_string<CharT,Traits,Alloc>
|
||||
basic_string( const Alloc& alloc = Alloc()) const;
|
||||
|
||||
|
||||
std::string string() const;
|
||||
std::wstring wstring() const;
|
||||
|
||||
const string_type & native_string() const;
|
||||
bool empty() const;
|
||||
|
||||
friend bool operator==(const key & l, const key & r);
|
||||
friend bool operator!=(const key & l, const key & r);
|
||||
friend bool operator<=(const key & l, const key & r);
|
||||
friend bool operator>=(const key & l, const key & r);
|
||||
friend bool operator< (const key & l, const key & r);
|
||||
friend bool operator> (const key & l, const key & r);
|
||||
|
||||
template< class CharT, class Traits >
|
||||
friend std::basic_ostream<CharT,Traits>&
|
||||
operator<<( std::basic_ostream<CharT,Traits>& os, const key& p );
|
||||
|
||||
template< class CharT, class Traits >
|
||||
friend std::basic_istream<CharT,Traits>&
|
||||
operator>>( std::basic_istream<CharT,Traits>& is, key& p );
|
||||
const value_type * data() const;
|
||||
std::size_t size() const;
|
||||
};
|
||||
|
||||
bool operator==(const value_view &, const value_view);
|
||||
bool operator!=(const value_view &, const value_view);
|
||||
bool operator<=(const value_view &, const value_view);
|
||||
bool operator< (const value_view &, const value_view);
|
||||
bool operator> (const value_view &, const value_view);
|
||||
bool operator>=(const value_view &, const value_view);
|
||||
|
||||
|
||||
struct value
|
||||
{
|
||||
using value_type = char_type;
|
||||
using traits_type = value_char_traits<char_type>;
|
||||
using string_type = std::basic_string<char_type, traits_type>;
|
||||
using string_view_type = basic_cstring_ref<char_type, traits_type>;
|
||||
|
||||
value();
|
||||
value( const value& p ) = default;
|
||||
|
||||
value( const string_type& source );
|
||||
value( string_type&& source );
|
||||
value( const value_type * raw );
|
||||
value( value_type * raw );
|
||||
|
||||
explicit value(value_view kv);
|
||||
|
||||
template< class Source >
|
||||
value( const Source& source );
|
||||
value(const typename conditional<is_same<value_type, char>::value, wchar_t, char>::type * raw);
|
||||
|
||||
template< class InputIt >
|
||||
value( InputIt first, InputIt last);
|
||||
|
||||
~value() = default;
|
||||
|
||||
value& operator=( const value& p ) = default;
|
||||
value& operator=( value&& p );
|
||||
value& operator=( string_type&& source );
|
||||
template< class Source >
|
||||
value& operator=( const Source& source );
|
||||
|
||||
value& assign( string_type&& source );
|
||||
template< class Source >
|
||||
value& assign( const Source& source );
|
||||
|
||||
template< class InputIt >
|
||||
value& assign( InputIt first, InputIt last );
|
||||
|
||||
void push_back(const value & sv);
|
||||
void clear() {value_.clear();}
|
||||
|
||||
void swap( value& other ) noexcept;
|
||||
|
||||
const value_type* c_str() const noexcept;
|
||||
const string_type& native() const noexcept;
|
||||
string_view_type native_view() const noexcept;
|
||||
|
||||
operator string_type() const;
|
||||
operator string_view_type() const;
|
||||
operator typename string_view_type::string_view_type() const;
|
||||
|
||||
int compare( const value& p ) const noexcept;
|
||||
int compare( const string_type& str ) const;
|
||||
int compare( string_view_type str ) const;
|
||||
int compare( const value_type* s ) const;
|
||||
|
||||
template< class CharT, class Traits = std::char_traits<CharT>,
|
||||
class Alloc = std::allocator<CharT> >
|
||||
std::basic_string<CharT,Traits,Alloc>
|
||||
basic_string( const Alloc& alloc = Alloc()) const;
|
||||
|
||||
std::string string() const;
|
||||
std::wstring wstring() const;
|
||||
|
||||
|
||||
const string_type & native_string() const;
|
||||
|
||||
bool empty() const;
|
||||
|
||||
friend bool operator==(const value & l, const value & r);
|
||||
friend bool operator!=(const value & l, const value & r);
|
||||
friend bool operator<=(const value & l, const value & r);
|
||||
friend bool operator>=(const value & l, const value & r);
|
||||
friend bool operator< (const value & l, const value & r);
|
||||
friend bool operator> (const value & l, const value & r);
|
||||
|
||||
template< class CharT, class Traits >
|
||||
friend std::basic_ostream<CharT,Traits>&
|
||||
operator<<( std::basic_ostream<CharT,Traits>& os, const value& p );
|
||||
|
||||
template< class CharT, class Traits >
|
||||
friend std::basic_istream<CharT,Traits>&
|
||||
operator>>( std::basic_istream<CharT,Traits>& is, value& p );
|
||||
|
||||
value_iterator begin() const;
|
||||
value_iterator end() const;
|
||||
const value_type * data() const;
|
||||
std::size_t size() const;
|
||||
};
|
||||
|
||||
|
||||
bool operator==(const value_view &, const value_view);
|
||||
bool operator!=(const value_view &, const value_view);
|
||||
bool operator<=(const value_view &, const value_view);
|
||||
bool operator< (const value_view &, const value_view);
|
||||
bool operator> (const value_view &, const value_view);
|
||||
bool operator>=(const value_view &, const value_view);
|
||||
|
||||
struct key_value_pair
|
||||
{
|
||||
using value_type = char_type;
|
||||
using traits_type = std::char_traits<char_type>;
|
||||
using string_type = std::basic_string<char_type>;
|
||||
using string_view_type = basic_cstring_ref<char_type>;
|
||||
|
||||
key_value_pair()l
|
||||
key_value_pair( const key_value_pair& p ) = default;
|
||||
key_value_pair( key_value_pair&& p ) noexcept = default;
|
||||
key_value_pair(key_view key, value_view value);
|
||||
|
||||
key_value_pair(key_view key, std::initializer_list<basic_string_view<char_type>> values);
|
||||
key_value_pair( const string_type& source );
|
||||
key_value_pair( string_type&& source );
|
||||
key_value_pair( const value_type * raw );
|
||||
key_value_pair( value_type * raw );
|
||||
|
||||
explicit key_value_pair(key_value_pair_view kv) : value_(kv.c_str()) {}
|
||||
|
||||
template< class Source >
|
||||
key_value_pair( const Source& source);
|
||||
|
||||
template< typename Key,
|
||||
typename Value >
|
||||
key_value_pair(
|
||||
const std::pair<Key, Value> & kv);
|
||||
|
||||
key_value_pair(const typename conditional<is_same<value_type, char>::value, wchar_t, char>::type * raw);
|
||||
|
||||
template< class InputIt , typename std::iterator_traits<InputIt>::iterator_category>
|
||||
key_value_pair( InputIt first, InputIt last );
|
||||
|
||||
~key_value_pair() = default;
|
||||
|
||||
key_value_pair& operator=( const key_value_pair& p ) = default;
|
||||
key_value_pair& operator=( key_value_pair&& p );
|
||||
key_value_pair& operator=( string_type&& source );
|
||||
template< class Source >
|
||||
key_value_pair& operator=( const Source& source );
|
||||
|
||||
key_value_pair& assign( string_type&& source );
|
||||
|
||||
template< class Source >
|
||||
key_value_pair& assign( const Source& source );
|
||||
|
||||
|
||||
template< class InputIt >
|
||||
key_value_pair& assign( InputIt first, InputIt last );
|
||||
|
||||
void clear();
|
||||
|
||||
void swap( key_value_pair& other ) noexcept;
|
||||
|
||||
const value_type* c_str() const noexcept;
|
||||
const string_type& native() const noexcept;
|
||||
string_view_type native_view() const noexcept;
|
||||
|
||||
operator string_type() const;
|
||||
operator string_view_type() const;
|
||||
operator typename string_view_type::string_view_type() const;
|
||||
operator key_value_pair_view() const;
|
||||
|
||||
int compare( const key_value_pair& p ) const noexcept;
|
||||
int compare( const string_type& str ) const;
|
||||
int compare( string_view_type str ) const;
|
||||
int compare( const value_type* s ) const;
|
||||
|
||||
template< class CharT, class Traits = std::char_traits<CharT>, class Alloc = std::allocator<CharT> >
|
||||
std::basic_string<CharT,Traits,Alloc>
|
||||
basic_string( const Alloc& alloc = Alloc() ) const;
|
||||
std::string string() const {return basic_string<char>();}
|
||||
std::wstring wstring() const {return basic_string<wchar_t>();}
|
||||
|
||||
const string_type & native_string() const;
|
||||
friend bool operator==(const key_value_pair & l, const key_value_pair & r);
|
||||
friend bool operator!=(const key_value_pair & l, const key_value_pair & r);
|
||||
friend bool operator<=(const key_value_pair & l, const key_value_pair & r);
|
||||
friend bool operator>=(const key_value_pair & l, const key_value_pair & r);
|
||||
friend bool operator< (const key_value_pair & l, const key_value_pair & r);
|
||||
friend bool operator> (const key_value_pair & l, const key_value_pair & r);
|
||||
|
||||
bool empty() const;
|
||||
|
||||
struct key_view key() const;
|
||||
struct value_view value() const;
|
||||
|
||||
template< class CharT, class Traits >
|
||||
friend std::basic_ostream<CharT,Traits>&
|
||||
operator<<( std::basic_ostream<CharT,Traits>& os, const key_value_pair& p );
|
||||
|
||||
template< class CharT, class Traits >
|
||||
friend std::basic_istream<CharT,Traits>&
|
||||
operator>>( std::basic_istream<CharT,Traits>& is, key_value_pair& p );
|
||||
|
||||
const value_type * data() const;
|
||||
std::size_t size() const;
|
||||
|
||||
template<std::size_t Idx>
|
||||
inline auto get() const -> typename conditional<Idx == 0u,environment::key_view, environment::value_view>::type;
|
||||
};
|
||||
|
||||
bool operator==(const key_value_pair_view &, const key_value_pair_view);
|
||||
bool operator!=(const key_value_pair_view &, const key_value_pair_view);
|
||||
bool operator<=(const key_value_pair_view &, const key_value_pair_view);
|
||||
bool operator< (const key_value_pair_view &, const key_value_pair_view);
|
||||
bool operator> (const key_value_pair_view &, const key_value_pair_view);
|
||||
bool operator>=(const key_value_pair_view &, const key_value_pair_view);
|
||||
|
||||
|
||||
// Allow tuple-likg getters & structured bindings.
|
||||
template<>
|
||||
key_view key_value_pair::get<0u>() const;
|
||||
|
||||
template<>
|
||||
value_view key_value_pair::get<1u>() const;
|
||||
|
||||
// A view object for the current environment of this process.
|
||||
/*
|
||||
* The view might (windows) or might not (posix) be owning;
|
||||
* if it owns it will deallocate the on destruction, like a unique_ptr.
|
||||
*
|
||||
* Note that accessing the environment in this way is not thread-safe.
|
||||
*
|
||||
* @code
|
||||
*
|
||||
* void dump_my_env(current_view env = current())
|
||||
* {
|
||||
* for (auto & [k, v] : env)
|
||||
* std::cout << k.string() << " = " << v.string() << std::endl;
|
||||
* }
|
||||
*
|
||||
* @endcode
|
||||
*
|
||||
*
|
||||
*/
|
||||
struct current_view
|
||||
{
|
||||
using native_handle_type = environment::native_handle_type;
|
||||
using value_type = key_value_pair_view;
|
||||
|
||||
current_view() = default;
|
||||
current_view(current_view && nt) = default;
|
||||
|
||||
native_handle_type native_handle() { return handle_.get(); }
|
||||
|
||||
struct iterator
|
||||
{
|
||||
using value_type = key_value_pair_view;
|
||||
using difference_type = int;
|
||||
using reference = key_value_pair_view;
|
||||
using pointer = key_value_pair_view;
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
|
||||
iterator() = default;
|
||||
iterator(const iterator & ) = default;
|
||||
iterator(const native_iterator &native_handle) : iterator_(native_handle) {}
|
||||
|
||||
iterator & operator++()
|
||||
{
|
||||
iterator_ = detail::next(iterator_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
iterator operator++(int)
|
||||
{
|
||||
auto last = *this;
|
||||
iterator_ = detail::next(iterator_);
|
||||
return last;
|
||||
}
|
||||
key_value_pair_view operator*() const
|
||||
{
|
||||
return detail::dereference(iterator_);
|
||||
}
|
||||
|
||||
friend bool operator==(const iterator & l, const iterator & r) {return l.iterator_ == r.iterator_;}
|
||||
friend bool operator!=(const iterator & l, const iterator & r) {return l.iterator_ != r.iterator_;}
|
||||
|
||||
private:
|
||||
environment::native_iterator iterator_;
|
||||
};
|
||||
|
||||
iterator begin() const {return iterator(handle_.get());}
|
||||
iterator end() const {return iterator(detail::find_end(handle_.get()));}
|
||||
|
||||
private:
|
||||
|
||||
std::unique_ptr<typename remove_pointer<native_handle_type>::type,
|
||||
detail::native_handle_deleter> handle_{environment::detail::load_native_handle()};
|
||||
};
|
||||
|
||||
// Obtain a handle to the current environment
|
||||
inline current_view current() {return current_view();}
|
||||
|
||||
// Find the home folder in an environment-like type.
|
||||
/*
|
||||
* @param env The environment to search. Defaults to the current environment of this process
|
||||
*
|
||||
* The environment type passed in must be a range with value T that fulfills the following requirements:
|
||||
*
|
||||
* For `T value`
|
||||
*
|
||||
* - std::get<0>(value) must return a type comparable to `key_view`.
|
||||
* - std::get<1>(value) must return a type convertible to filesystem::path.
|
||||
*
|
||||
* @return A filesystem::path to the home directory or an empty path if it cannot be found.
|
||||
*
|
||||
*/
|
||||
template<typename Environment = current_view>
|
||||
inline filesystem::path home(Environment && env = current());
|
||||
|
||||
// Find the executable `name` in an environment-like type.
|
||||
template<typename Environment = current_view>
|
||||
filesystem::path find_executable(BOOST_PROCESS_V2_NAMESPACE::filesystem::path name,
|
||||
Environment && env = current());
|
||||
|
||||
// Get an environment variable from the current process.
|
||||
value get(const key & k, error_code & ec);
|
||||
value get(const key & k);
|
||||
value get(basic_cstring_ref<char_type, key_char_traits<char_type>> k, error_code & ec);
|
||||
value get(basic_cstring_ref<char_type, key_char_traits<char_type>> k);
|
||||
value get(const char_type * c, error_code & ec);
|
||||
value get(const char_type * c);
|
||||
|
||||
// Set an environment variable for the current process.
|
||||
void set(const key & k, value_view vw, error_code & ec);
|
||||
void set(const key & k, value_view vw);
|
||||
void set(basic_cstring_ref<char_type, key_char_traits<char_type>> k, value_view vw, error_code & ec);
|
||||
void set(basic_cstring_ref<char_type, key_char_traits<char_type>> k, value_view vw);
|
||||
void set(const char_type * k, value_view vw, error_code & ec);
|
||||
void set(const char_type * k, value_view vw);
|
||||
template<typename Char>
|
||||
void set(const key & k, const Char * vw, error_code & ec);
|
||||
template<typename Char>
|
||||
void set(const key & k, const Char * vw);
|
||||
template<typename Char>
|
||||
void set(basic_cstring_ref<char_type, key_char_traits<char_type>> k, const Char * vw, error_code & ec);
|
||||
template<typename Char>
|
||||
void set(basic_cstring_ref<char_type, key_char_traits<char_type>> k, const Char * vw);
|
||||
template<typename Char>
|
||||
void set(const char_type * k, const Char * vw, error_code & ec);
|
||||
template<typename Char>
|
||||
void set(const char_type * k, const Char * vw);
|
||||
|
||||
// Remove an environment variable from the current process.
|
||||
void unset(const key & k, error_code & ec);
|
||||
void unset(const key & k);
|
||||
void unset(basic_cstring_ref<char_type, key_char_traits<char_type>> k, error_code & ec);
|
||||
void unset(basic_cstring_ref<char_type, key_char_traits<char_type>> k);
|
||||
void unset(const char_type * c, error_code & ec);
|
||||
void unset(const char_type * c);
|
||||
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
=== `process_environment`
|
||||
|
||||
In order to set the environment of a child process, `process_environment` can be used.
|
||||
|
||||
|
||||
|
||||
[source, cpp]
|
||||
.This will set the environment in a subprocess:
|
||||
----
|
||||
process proc{executor, find_executable("printenv"), {"foo"}, process_environment{"foo=bar"}};
|
||||
----
|
||||
|
||||
The environment initializer will persist it's state, so that it can
|
||||
be used multiple times. Do however note the the Operating System is
|
||||
allowed to modify the internal state.
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
auto exe = find_executable("printenv");
|
||||
process_environment env = {"FOO=BAR", "BAR=FOO"};
|
||||
|
||||
process proc1(executor, exe, {"FOO"}, env);
|
||||
process proc2(executor, exe, {"BAR"}, env);
|
||||
----
|
||||
36
doc/reference/error.adoc
Normal file
36
doc/reference/error.adoc
Normal file
@@ -0,0 +1,36 @@
|
||||
== `error.hpp`
|
||||
[#error]
|
||||
|
||||
The error header provides two error categories:
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
// Errors used for utf8 <-> UCS-2 conversions.
|
||||
enum utf8_conv_error
|
||||
{
|
||||
insufficient_buffer = 1,
|
||||
invalid_character,
|
||||
};
|
||||
|
||||
extern const error_category& get_utf8_category();
|
||||
static const error_category& utf8_category = get_utf8_category();
|
||||
|
||||
extern const error_category& get_exit_code_category();
|
||||
|
||||
/// An error category that can be used to interpret exit codes of subprocesses.
|
||||
static const error_category& exit_code_category = get_exit_code_category();
|
||||
|
||||
}
|
||||
----
|
||||
|
||||
The `get_exit_code_category` can be used as follows:
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
void run_my_process(filesystem::path pt, error_code & ec)
|
||||
{
|
||||
process proc(pt, {});
|
||||
proc.wait();
|
||||
ec.assign(proc.native_exit_code(), error::get_exit_code_category());
|
||||
}
|
||||
----
|
||||
33
doc/reference/execute.adoc
Normal file
33
doc/reference/execute.adoc
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
== `execute.hpp`
|
||||
[#execute]
|
||||
|
||||
The execute header provides two error categories:
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
|
||||
// Run a process and wait for it to complete.
|
||||
template<typename Executor> int execute(basic_process<Executor> proc);
|
||||
template<typename Executor> int execute(basic_process<Executor> proc, error_code & ec)
|
||||
|
||||
// Execute a process asynchronously
|
||||
template<typename Executor = net::any_io_executor,
|
||||
BOOST_PROCESS_V2_COMPLETION_TOKEN_FOR(void (error_code, int))
|
||||
WaitHandler = net::default_completion_token_t<Executor>>
|
||||
auto async_execute(basic_process<Executor> proc,
|
||||
WaitHandler && handler = net::default_completion_token_t<Executor>());
|
||||
----
|
||||
|
||||
The `async_execute` function asynchronously for a process to complete.
|
||||
|
||||
Cancelling the execution will signal the child process to exit
|
||||
with the following interpretations:
|
||||
|
||||
- `cancellation_type::total` -> interrupt
|
||||
- `cancellation_type::partial` -> request_exit
|
||||
- `cancellation_type::terminal` -> terminate
|
||||
|
||||
It is to note that `async_execute` will use the lowest selected cancellation
|
||||
type. A subprocess might ignore anything not terminal.
|
||||
|
||||
43
doc/reference/exit_code.adoc
Normal file
43
doc/reference/exit_code.adoc
Normal file
@@ -0,0 +1,43 @@
|
||||
== `exit_code.hpp`
|
||||
[#exit_code]
|
||||
|
||||
The exit code header provides portable handles for exit codes.
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
// The native exit-code type, usually an integral value
|
||||
/* The OS may have a value different from `int` to represent
|
||||
* the exit codes of subprocesses. It might also
|
||||
* contain additional information.
|
||||
*/
|
||||
typedef implementation_defined native_exit_code_type;
|
||||
|
||||
|
||||
// Check if the native exit code indicates the process is still running
|
||||
bool process_is_running(native_exit_code_type code);
|
||||
|
||||
// Obtain the portable part of the exit code, i.e. what the subprocess has returned from main.
|
||||
int evaluate_exit_code(native_exit_code_type code);
|
||||
|
||||
// Helper to subsume an exit-code into an error_code if there's no actual error isn't set.
|
||||
error_code check_exit_code(
|
||||
error_code &ec, native_exit_code_type native_code,
|
||||
const error_category & category = error::get_exit_code_category());
|
||||
----
|
||||
|
||||
|
||||
The `check_exit_code` can be used like this:
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
|
||||
process proc{co_await this_coro::executor, "exit", {"1"}};
|
||||
|
||||
co_await proc.async_wait(
|
||||
asio::deferred(
|
||||
[&proc](error_code ec, int)
|
||||
{
|
||||
return asio::deferred.values(
|
||||
check_exit_code(ec, proc.native_exit_code())
|
||||
);
|
||||
----
|
||||
46
doc/reference/ext.adoc
Normal file
46
doc/reference/ext.adoc
Normal file
@@ -0,0 +1,46 @@
|
||||
== `ext`
|
||||
|
||||
The headers in `process/ext` provides features to obtain information about third part processes.
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
// Get the cmd line used to launche the process
|
||||
template<typename Executor>
|
||||
shell cmd(basic_process_handle<Executor> & handle, error_code & ec);
|
||||
template<typename Executor>
|
||||
shell cmd(basic_process_handle<Executor> & handle);
|
||||
shell cmd(pid_type pid, error_code & ec);
|
||||
shell cmd(pid_type pid);
|
||||
|
||||
|
||||
// Get the current working directory of the process.
|
||||
template<typename Executor>
|
||||
filesystem::path cwd(basic_process_handle<Executor> & handle, error_code & ec);
|
||||
template<typename Executor>
|
||||
filesystem::path cwd(basic_process_handle<Executor> & handle)
|
||||
filesystem::path cwd(pid_type pid, error_code & ec);
|
||||
filesystem::path cwd(pid_type pid);
|
||||
|
||||
|
||||
// Get the current environment of the process.
|
||||
template<typename Executor>
|
||||
env_view cwd(basic_process_handle<Executor> & handle, error_code & ec);
|
||||
template<typename Executor>
|
||||
env_view cwd(basic_process_handle<Executor> & handle)
|
||||
env_view env(pid_type pid, error_code & ec);
|
||||
env_view env(pid_type pid);
|
||||
|
||||
|
||||
// Get the executable of the process.
|
||||
template<typename Executor>
|
||||
filesystem::path exe(basic_process_handle<Executor> & handle, error_code & ec);
|
||||
template<typename Executor>
|
||||
filesystem::path exe(basic_process_handle<Executor> & handle)
|
||||
filesystem::path exe(pid_type pid, error_code & ec);
|
||||
filesystem::path exe(pid_type pid);
|
||||
----
|
||||
|
||||
WARNING: The function may fail with "operation_not_supported" on some niche platforms.
|
||||
|
||||
NOTE: On windows overloads taking a `HANDLE` are also available.
|
||||
|
||||
23
doc/reference/pid.adoc
Normal file
23
doc/reference/pid.adoc
Normal file
@@ -0,0 +1,23 @@
|
||||
== `pid.hpp`
|
||||
[#pid]
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
//An integral type representing a process id.
|
||||
typedef implementation_defined pid_type;
|
||||
|
||||
// Get the process id of the current process.
|
||||
pid_type current_pid();
|
||||
|
||||
// List all available pids.
|
||||
std::vector<pid_type> all_pids(boost::system::error_code & ec);
|
||||
std::vector<pid_type> all_pids();
|
||||
|
||||
// return parent pid of pid.
|
||||
pid_type parent_pid(pid_type pid, boost::system::error_code & ec);
|
||||
pid_type parent_pid(pid_type pid);
|
||||
|
||||
// return child pids of pid.
|
||||
std::vector<pid_type> child_pids(pid_type pid, boost::system::error_code & ec);
|
||||
std::vector<pid_type> child_pids(pid_type pid);
|
||||
----
|
||||
163
doc/reference/popen.adoc
Normal file
163
doc/reference/popen.adoc
Normal file
@@ -0,0 +1,163 @@
|
||||
== `popen.hpp`
|
||||
[#popen]
|
||||
|
||||
`popen` is a class that launches a process and connect stdin & stdout to pipes.
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
popen proc(executor, find_executable("addr2line"), {argv[0]});
|
||||
asio::write(proc, asio::buffer("main\n"));
|
||||
std::string line;
|
||||
asio::read_until(proc, asio::dynamic_buffer(line), '\n');
|
||||
----
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
// A subprocess with automatically assigned pipes.
|
||||
template<typename Executor = net::any_io_executor>
|
||||
struct basic_popen : basic_process<Executor>
|
||||
{
|
||||
// The executor of the process
|
||||
using executor_type = Executor;
|
||||
|
||||
// Rebinds the popen type to another executor.
|
||||
template <typename Executor1>
|
||||
struct rebind_executor
|
||||
{
|
||||
// The pipe type when rebound to the specified executor.
|
||||
typedef basic_popen<Executor1> other;
|
||||
};
|
||||
|
||||
// Move construct a popen
|
||||
basic_popen(basic_popen &&) = default;
|
||||
// Move assign a popen
|
||||
basic_popen& operator=(basic_popen &&) = default;
|
||||
|
||||
// Move construct a popen and change the executor type.
|
||||
template<typename Executor1>
|
||||
basic_popen(basic_popen<Executor1>&& lhs)
|
||||
: basic_process<Executor>(std::move(lhs)),
|
||||
stdin_(std::move(lhs.stdin_)), stdout_(std::move(lhs.stdout_))
|
||||
{
|
||||
}
|
||||
|
||||
// Create a closed process handle
|
||||
explicit basic_popen(executor_type exec);
|
||||
|
||||
// Create a closed process handle
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_popen(ExecutionContext & context);
|
||||
|
||||
// Construct a child from a property list and launch it using the default process launcher.
|
||||
template<typename ... Inits>
|
||||
explicit basic_popen(
|
||||
executor_type executor,
|
||||
const filesystem::path& exe,
|
||||
std::initializer_list<string_view> args,
|
||||
Inits&&... inits);
|
||||
|
||||
// Construct a child from a property list and launch it using the default process launcher.
|
||||
template<typename Launcher, typename ... Inits>
|
||||
explicit basic_popen(
|
||||
Launcher && launcher,
|
||||
executor_type executor,
|
||||
const filesystem::path& exe,
|
||||
std::initializer_list<string_view> args,
|
||||
Inits&&... inits);
|
||||
|
||||
// Construct a child from a property list and launch it using the default process launcher.
|
||||
template<typename Args, typename ... Inits>
|
||||
explicit basic_popen(
|
||||
executor_type executor,
|
||||
const filesystem::path& exe,
|
||||
Args&& args, Inits&&... inits);
|
||||
|
||||
// Construct a child from a property list and launch it using the default process launcher.
|
||||
template<typename Launcher, typename Args, typename ... Inits>
|
||||
explicit basic_popen(
|
||||
Launcher && launcher,
|
||||
executor_type executor,
|
||||
const filesystem::path& exe,
|
||||
Args&& args, Inits&&... inits);
|
||||
|
||||
// Construct a child from a property list and launch it using the default process launcher.
|
||||
template<typename ExecutionContext, typename ... Inits>
|
||||
explicit basic_popen(
|
||||
ExecutionContext & context,
|
||||
const filesystem::path& exe,
|
||||
std::initializer_list<string_view> args,
|
||||
Inits&&... inits);
|
||||
|
||||
// Construct a child from a property list and launch it using the default process launcher.
|
||||
template<typename Launcher, typename ExecutionContext, typename ... Inits>
|
||||
explicit basic_popen(
|
||||
Launcher && launcher,
|
||||
ExecutionContext & context,
|
||||
const filesystem::path& exe,
|
||||
std::initializer_list<string_view> args,
|
||||
Inits&&... inits);
|
||||
|
||||
// Construct a child from a property list and launch it using the default process launcher.
|
||||
template<typename ExecutionContext, typename Args, typename ... Inits>
|
||||
explicit basic_popen(
|
||||
ExecutionContext & context,
|
||||
const filesystem::path& exe,
|
||||
Args&& args, Inits&&... inits);
|
||||
|
||||
// Construct a child from a property list and launch it using the default process launcher.
|
||||
template<typename Launcher, typename ExecutionContext, typename Args, typename ... Inits>
|
||||
explicit basic_popen(
|
||||
Launcher && launcher,
|
||||
ExecutionContext & context,
|
||||
const filesystem::path& exe,
|
||||
Args&& args, Inits&&... inits);
|
||||
|
||||
// The type used for stdin on the parent process side.
|
||||
using stdin_type = net::basic_writable_pipe<Executor>;
|
||||
// The type used for stdout on the parent process side.
|
||||
using stdout_type = net::basic_readable_pipe<Executor>;
|
||||
|
||||
// Get the stdin pipe.
|
||||
|
||||
// Get the stdout pipe.
|
||||
|
||||
// Get the stdin pipe.
|
||||
stdin_type & get_stdin();
|
||||
const stdin_type & get_stdin() const;
|
||||
// Get the stdout pipe.
|
||||
stdout_type & get_stdout();
|
||||
const stdout_type & get_stdout() const;
|
||||
|
||||
// Write some data to the stdin pipe.
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers);
|
||||
template <typename ConstBufferSequence>
|
||||
std::size_t write_some(const ConstBufferSequence& buffers,
|
||||
boost::system::error_code& ec);
|
||||
|
||||
// Start an asynchronous write.
|
||||
template <typename ConstBufferSequence,
|
||||
BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code, std::size_t))
|
||||
WriteToken = net::default_completion_token_t<executor_type>>
|
||||
auto async_write_some(const ConstBufferSequence& buffers,
|
||||
WriteToken && token = net::default_completion_token_t<executor_type>());
|
||||
|
||||
// Read some data from the stdout pipe.
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers);
|
||||
template <typename MutableBufferSequence>
|
||||
std::size_t read_some(const MutableBufferSequence& buffers,
|
||||
boost::system::error_code& ec)
|
||||
|
||||
// Start an asynchronous read. template <typename MutableBufferSequence,
|
||||
BOOST_PROCESS_V2_COMPLETION_TOKEN_FOR(void (boost::system::error_code, std::size_t))
|
||||
ReadToken = net::default_completion_token_t<executor_type>>
|
||||
auto async_read_some(const MutableBufferSequence& buffers,
|
||||
BOOST_ASIO_MOVE_ARG(ReadToken) token
|
||||
= net::default_completion_token_t<executor_type>());
|
||||
};
|
||||
|
||||
// A popen object with the default executor.
|
||||
using popen = basic_popen<>;
|
||||
|
||||
----
|
||||
70
doc/reference/posix/bind_fd.adoc
Normal file
70
doc/reference/posix/bind_fd.adoc
Normal file
@@ -0,0 +1,70 @@
|
||||
== `posix/bind_fd.hpp`
|
||||
|
||||
`bind_fd` is a utility class to bind a file descriptor to an explicit file descriptor for the child process.
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
struct bind_fd
|
||||
{
|
||||
// Inherit file descriptor with the same value.
|
||||
/*
|
||||
* This will pass descriptor 42 as 42 to the child process:
|
||||
* @code
|
||||
* process p{"test", {}, posix::bind_fd(42)};
|
||||
* @endcode
|
||||
*/
|
||||
bind_fd(int target);
|
||||
|
||||
// Inherit an asio io-object as a given file descriptor to the child process.
|
||||
/*
|
||||
* This will pass the tcp::socket, as 42 to the child process:
|
||||
* @code
|
||||
* extern tcp::socket sock;
|
||||
* process p{"test", {}, posix::bind_fd(42, sock)};
|
||||
* @endcode
|
||||
*/
|
||||
|
||||
template<typename Stream>
|
||||
bind_fd(int target, Stream && str);
|
||||
|
||||
// Inherit a `FILE` as a given file descriptor to the child process.
|
||||
/* This will pass the given `FILE*`, as 42 to the child process:
|
||||
|
||||
process p{"test", {}, posix::bind_fd(42, stderr)};
|
||||
|
||||
*/
|
||||
bind_fd(int target, FILE * f);
|
||||
|
||||
// Inherit a file descriptor with as a different value.
|
||||
/* This will pass 24 as 42 to the child process:
|
||||
|
||||
process p{"test", {}, posix::bind_fd(42, 24)};
|
||||
|
||||
*/
|
||||
bind_fd(int target, int fd);
|
||||
|
||||
// Inherit a null device as a set descriptor.
|
||||
/* This will a null device as 42 to the child process:
|
||||
|
||||
process p{"test", {}, posix::bind_fd(42, nullptr)};
|
||||
|
||||
*/
|
||||
bind_fd(int target, std::nullptr_t);
|
||||
|
||||
// Inherit a newly opened-file as a set descriptor.
|
||||
/* This will pass a descriptor to "extra-output.txt" as 42 to the child process:
|
||||
|
||||
process p{"test", {}, posix::bind_fd(42, "extra-output.txt")};
|
||||
|
||||
*/
|
||||
bind_fd(int target, const filesystem::path & pth, int flags = O_RDWR | O_CREAT);
|
||||
|
||||
};
|
||||
----
|
||||
|
||||
Using `bind_fd` can be used to inherit file descriptors explicitly, because no unused one will be.
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
|
||||
----
|
||||
174
doc/reference/process.adoc
Normal file
174
doc/reference/process.adoc
Normal file
@@ -0,0 +1,174 @@
|
||||
== `process.hpp`
|
||||
[#process]
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
// A class managing a subprocess
|
||||
/* A `basic_process` object manages a subprocess; it tracks the status and exit-code,
|
||||
* and will terminate the process on destruction if `detach` was not called.
|
||||
*/
|
||||
template<typename Executor = net::any_io_executor>
|
||||
struct basic_process
|
||||
{
|
||||
// The executor of the process
|
||||
using executor_type = Executor;
|
||||
// Get the executor of the process
|
||||
executor_type get_executor() {return process_handle_.get_executor();}
|
||||
|
||||
// The non-closing handle type
|
||||
using handle_type = basic_process_handle<executor_type>;
|
||||
|
||||
// Get the underlying non-closing handle
|
||||
handle_type & handle() { return process_handle_; }
|
||||
|
||||
// Get the underlying non-closing handle
|
||||
const handle_type & handle() const { return process_handle_; }
|
||||
|
||||
// Provides access to underlying operating system facilities
|
||||
using native_handle_type = typename handle_type::native_handle_type;
|
||||
|
||||
// Rebinds the process_handle to another executor.
|
||||
template <typename Executor1>
|
||||
struct rebind_executor
|
||||
{
|
||||
// The socket type when rebound to the specified executor.
|
||||
typedef basic_process<Executor1> other;
|
||||
};
|
||||
|
||||
/** An empty process is similar to a default constructed thread. It holds an empty
|
||||
handle and is a place holder for a process that is to be launched later. */
|
||||
basic_process() = default;
|
||||
|
||||
basic_process(const basic_process&) = delete;
|
||||
basic_process& operator=(const basic_process&) = delete;
|
||||
|
||||
// Move construct the process. It will be detached from `lhs`.
|
||||
basic_process(basic_process&& lhs) = default;
|
||||
|
||||
// Move assign a process. It will be detached from `lhs`.
|
||||
basic_process& operator=(basic_process&& lhs) = default;
|
||||
|
||||
// Move construct and rebind the executor.
|
||||
template<typename Executor1>
|
||||
basic_process(basic_process<Executor1>&& lhs);
|
||||
|
||||
// Construct a child from a property list and launch it using the default launcher..
|
||||
template<typename ... Inits>
|
||||
explicit basic_process(
|
||||
executor_type executor,
|
||||
const filesystem::path& exe,
|
||||
std::initializer_list<string_view> args,
|
||||
Inits&&... inits);
|
||||
|
||||
// Construct a child from a property list and launch it using the default launcher..
|
||||
template<typename Args, typename ... Inits>
|
||||
explicit basic_process(
|
||||
executor_type executor,
|
||||
const filesystem::path& exe,
|
||||
Args&& args, Inits&&... inits);
|
||||
|
||||
// Construct a child from a property list and launch it using the default launcher..
|
||||
template<typename ExecutionContext, typename ... Inits>
|
||||
explicit basic_process(
|
||||
ExecutionContext & context,
|
||||
const filesystem::path& exe,
|
||||
std::initializer_list<string_view> args,
|
||||
Inits&&... inits);
|
||||
// Construct a child from a property list and launch it using the default launcher.
|
||||
template<typename ExecutionContext, typename Args, typename ... Inits>
|
||||
explicit basic_process(
|
||||
ExecutionContext & context,
|
||||
const filesystem::path& exe,
|
||||
Args&& args, Inits&&... inits);
|
||||
|
||||
// Attach to an existing process
|
||||
explicit basic_process(executor_type exec, pid_type pid);
|
||||
|
||||
// Attach to an existing process and the internal handle
|
||||
explicit basic_process(executor_type exec, pid_type pid, native_handle_type native_handle);
|
||||
|
||||
// Create an invalid handle
|
||||
explicit basic_process(executor_type exec);
|
||||
|
||||
// Attach to an existing process
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_process(ExecutionContext & context, pid_type pid);
|
||||
|
||||
// Attach to an existing process and the internal handle
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_process(ExecutionContext & context, pid_type pid, native_handle_type native_handle);
|
||||
|
||||
// Create an invalid handle
|
||||
template <typename ExecutionContext>
|
||||
explicit basic_process(ExecutionContext & context);
|
||||
|
||||
|
||||
|
||||
// Destruct the handle and terminate the process if it wasn't detached.
|
||||
~basic_process();
|
||||
|
||||
// Sends the process a signal to ask for an interrupt, which the process may interpret as a shutdown.
|
||||
/** Maybe be ignored by the subprocess. */
|
||||
void interrupt(error_code & ec);
|
||||
void interrupt();
|
||||
|
||||
// Throwing @overload void interrupt()
|
||||
|
||||
|
||||
// Sends the process a signal to ask for a graceful shutdown. Maybe be ignored by the subprocess.
|
||||
void request_exit(error_code & ec);
|
||||
void request_exit();
|
||||
|
||||
// Send the process a signal requesting it to stop. This may rely on undocumented functions.
|
||||
void suspend(error_code &ec);
|
||||
void suspend();
|
||||
|
||||
|
||||
// Send the process a signal requesting it to resume. This may rely on undocumented functions.
|
||||
void resume(error_code &ec);
|
||||
void resume();
|
||||
|
||||
// Unconditionally terminates the process and stores the exit code in exit_status.
|
||||
void terminate(error_code & ec);
|
||||
void terminate();
|
||||
|
||||
// Waits for the process to exit, store the exit code internally and return it.
|
||||
int wait(error_code & ec);
|
||||
int wait();
|
||||
|
||||
// Detach the process.
|
||||
handle_type detach();
|
||||
// Get the native
|
||||
native_handle_type native_handle() {return process_handle_.native_handle(); }
|
||||
|
||||
// Return the evaluated exit_code.
|
||||
int exit_code() const;
|
||||
|
||||
// Get the id of the process;
|
||||
pid_type id() const;
|
||||
|
||||
// The native handle of the process.
|
||||
/** This might be undefined on posix systems that only support signals */
|
||||
native_exit_code_type native_exit_code() const;
|
||||
|
||||
// Checks if the current process is running.
|
||||
/* If it has already completed the exit code will be stored internally
|
||||
* and can be obtained by calling `exit_code.
|
||||
*/
|
||||
bool running();
|
||||
bool running(error_code & ec) noexcept;
|
||||
|
||||
// Check if the process is referring to an existing process.
|
||||
/** Note that this might be a process that already exited.*/
|
||||
bool is_open() const;
|
||||
|
||||
// Asynchronously wait for the process to exit and deliver the native exit-code in the completion handler.
|
||||
template <BOOST_PROCESS_V2_COMPLETION_TOKEN_FOR(void (error_code, int))
|
||||
WaitHandler = net::default_completion_token_t<executor_type>>
|
||||
auto async_wait(WaitHandler && handler = net::default_completion_token_t<executor_type>());
|
||||
};
|
||||
|
||||
// Process with the default executor.
|
||||
typedef basic_process<> process;
|
||||
|
||||
----
|
||||
109
doc/reference/process_handle.adoc
Normal file
109
doc/reference/process_handle.adoc
Normal file
@@ -0,0 +1,109 @@
|
||||
== `process_handle.hpp`
|
||||
[#process_handle]
|
||||
|
||||
A process handle is an unmanaged version of a process.
|
||||
This means it does not terminate the process on destruction and
|
||||
will not keep track of the exit-code.
|
||||
|
||||
NOTE: that the exit code might be discovered early, during a call to `running`.
|
||||
Thus it can only be discovered that process has exited already.
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
|
||||
template<typename Executor = net::any_io_executor>
|
||||
struct basic_process_handle
|
||||
{
|
||||
// The native handle of the process.
|
||||
/* This might be undefined on posix systems that only support signals */
|
||||
using native_handle_type = implementation_defined;
|
||||
|
||||
// The executor_type of the process_handle
|
||||
using executor_type = Executor;
|
||||
|
||||
// Getter for the executor
|
||||
executor_type get_executor();
|
||||
|
||||
// Rebinds the process_handle to another executor.
|
||||
template<typename Executor1>
|
||||
struct rebind_executor
|
||||
{
|
||||
// The socket type when rebound to the specified executor.
|
||||
typedef basic_process_handle<Executor1> other;
|
||||
};
|
||||
|
||||
|
||||
// Construct a basic_process_handle from an execution_context.
|
||||
/*
|
||||
* @tparam ExecutionContext The context must fulfill the asio::execution_context requirements
|
||||
*/
|
||||
template<typename ExecutionContext>
|
||||
basic_process_handle(ExecutionContext &context);
|
||||
|
||||
// Construct an empty process_handle from an executor.
|
||||
basic_process_handle(executor_type executor);
|
||||
|
||||
// Construct an empty process_handle from an executor and bind it to a pid.
|
||||
/* On NON-linux posix systems this call is not able to obtain a file-descriptor and will thus
|
||||
* rely on signals.
|
||||
*/
|
||||
basic_process_handle(executor_type executor, pid_type pid);
|
||||
|
||||
// Construct an empty process_handle from an executor and bind it to a pid and the native-handle
|
||||
/* On some non-linux posix systems this overload is not present.
|
||||
*/
|
||||
basic_process_handle(executor_type executor, pid_type pid, native_handle_type process_handle);
|
||||
|
||||
// Move construct and rebind the executor.
|
||||
template<typename Executor1>
|
||||
basic_process_handle(basic_process_handle<Executor1> &&handle);
|
||||
|
||||
// Get the id of the process
|
||||
pid_type id() const
|
||||
{ return pid_; }
|
||||
|
||||
// Terminate the process if it's still running and ignore the result
|
||||
void terminate_if_running(error_code &);
|
||||
|
||||
// Throwing @overload void terminate_if_running(error_code & ec;
|
||||
void terminate_if_running();
|
||||
// wait for the process to exit and store the exit code in exit_status.
|
||||
void wait(native_exit_code_type &exit_status, error_code &ec);
|
||||
// Throwing @overload wait(native_exit_code_type &exit_code, error_code & ec)
|
||||
void wait(native_exit_code_type &exit_status);
|
||||
|
||||
// Sends the process a signal to ask for an interrupt, which the process may interpret as a shutdown.
|
||||
/* Maybe be ignored by the subprocess. */
|
||||
void interrupt(error_code &ec);
|
||||
|
||||
// Throwing @overload void interrupt()
|
||||
void interrupt();
|
||||
|
||||
// Sends the process a signal to ask for a graceful shutdown. Maybe be ignored by the subprocess.
|
||||
void request_exit(error_code &ec);
|
||||
|
||||
// Throwing @overload void request_exit(error_code & ec)
|
||||
void request_exit()
|
||||
|
||||
// Unconditionally terminates the process and stores the exit code in exit_status.
|
||||
void terminate(native_exit_code_type &exit_status, error_code &ec);\
|
||||
// Throwing @overload void terminate(native_exit_code_type &exit_code, error_code & ec)
|
||||
void terminate(native_exit_code_type &exit_status);/
|
||||
|
||||
// Checks if the current process is running.
|
||||
/*If it has already completed, it assigns the exit code to `exit_code`.
|
||||
*/
|
||||
bool running(native_exit_code_type &exit_code, error_code &ec);
|
||||
// Throwing @overload bool running(native_exit_code_type &exit_code, error_code & ec)
|
||||
bool running(native_exit_code_type &exit_code);
|
||||
|
||||
// Check if the process handle is referring to an existing process.
|
||||
bool is_open() const;
|
||||
|
||||
// Asynchronously wait for the process to exit and assign the native exit-code to the reference.
|
||||
// The exit_status can indicate that a process has already be waited for, e.g. when terminate is called.
|
||||
template<BOOST_PROCESS_V2_COMPLETION_TOKEN_FOR(void(error_code))
|
||||
WaitHandler = net::default_completion_token_t<executor_type>>
|
||||
auto async_wait(native_exit_code_type &exit_status, WaitHandler &&handler = net::default_completion_token_t<executor_type>());
|
||||
};
|
||||
----
|
||||
57
doc/reference/shell.adoc
Normal file
57
doc/reference/shell.adoc
Normal file
@@ -0,0 +1,57 @@
|
||||
== `shell.hpp`
|
||||
[#shell]
|
||||
|
||||
This utility class parses command lines into tokens
|
||||
and allows users to execute processes based on textual inputs.
|
||||
|
||||
In v1, this was possible directly when starting a process,
|
||||
but has been removed based on the security risks associated with this.
|
||||
|
||||
By making the shell parsing explicitly, it encourages
|
||||
a user to run a sanity check on the executable before launching it.
|
||||
|
||||
.Example
|
||||
[source,cpp]
|
||||
----
|
||||
asio::io_context ctx;
|
||||
|
||||
auto cmd = shell("my-app --help");
|
||||
auto exe = cmd.exe();
|
||||
check_if_malicious(exe);
|
||||
|
||||
process proc{ctx, exe, cmd.args()};
|
||||
|
||||
----
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
/// Utility to parse commands
|
||||
struct shell
|
||||
{
|
||||
shell() = default;
|
||||
template<typename Char, typename Traits>
|
||||
shell(basic_string_view<Char, Traits> input);
|
||||
|
||||
shell(basic_cstring_ref<char_type> input);
|
||||
shell(const shell &) = delete;
|
||||
shell(shell && lhs) noexcept;
|
||||
shell& operator=(const shell &) = delete;
|
||||
shell& operator=(shell && lhs) noexcept;
|
||||
|
||||
|
||||
// the length of the parsed shell, including the executable
|
||||
int argc() const ;
|
||||
char_type** argv() const;
|
||||
|
||||
char_type** begin() const;
|
||||
char_type** end() const;
|
||||
|
||||
bool empty() const;
|
||||
std::size_t size() const;
|
||||
|
||||
// Native representation of the arguments to be used - excluding the executable
|
||||
args_type args() const;
|
||||
template<typename Environment = environment::current_view>
|
||||
filesystem::path exe(Environment && env = environment::current()) const;
|
||||
};
|
||||
----
|
||||
16
doc/reference/start_dir.adoc
Normal file
16
doc/reference/start_dir.adoc
Normal file
@@ -0,0 +1,16 @@
|
||||
== `start_dir.hpp`
|
||||
[#start_dir]
|
||||
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
/// Initializer for the starting directory of a subprocess to be launched.
|
||||
struct process_start_dir
|
||||
{
|
||||
filesystem::path start_dir;
|
||||
|
||||
process_start_dir(filesystem::path start_dir);
|
||||
{
|
||||
}
|
||||
};
|
||||
----
|
||||
100
doc/reference/stdio.adoc
Normal file
100
doc/reference/stdio.adoc
Normal file
@@ -0,0 +1,100 @@
|
||||
== `stdio.hpp`
|
||||
[#stdio]
|
||||
|
||||
The initializer for the stdio of a subprocess
|
||||
The subprocess stdio initializer has three members:
|
||||
|
||||
- in for stdin
|
||||
- out for stdout
|
||||
- err for stderr
|
||||
|
||||
If the initializer is present all three will be set for the subprocess.
|
||||
By default they will inherit the stdio handles from the parent process.
|
||||
This means that this will forward stdio to the subprocess:
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
asio::io_context ctx;
|
||||
v2::process proc(ctx, "/bin/bash", {}, v2::process_stdio{});
|
||||
----
|
||||
|
||||
No constructors are provided in order to support designated initializers
|
||||
in later version of C++.
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
asio::io_context ctx;
|
||||
|
||||
/// C++17
|
||||
v2::process proc17(ctx, "/bin/bash", {}, v2::process_stdio{.err=nullptr});
|
||||
/// C++11 & C++14
|
||||
v2::process proc17(ctx, "/bin/bash", {}, v2::process_stdio{ {}, {}, nullptr});
|
||||
----
|
||||
|
||||
Valid initializers for any stdio are:
|
||||
|
||||
- `std::nullptr_t` assigning a null-device
|
||||
- `FILE*` any open file, including `stdin`, `stdout` and `stderr`
|
||||
- `native_handle` any native file handle (`HANDLE` on windows) or file descriptor (`int` on posix)
|
||||
- any io-object with a `.native_handle()` function that is compatible with the above. E.g. a `asio::ip::tcp::socket`, or a pipe object.
|
||||
- a filesystem::path, which will open a readable or writable depending on the direction of the stream
|
||||
- an `asio::basic_writeable_pipe` for stdin or `asio::basic_readable_pipe` for stderr/stdout.
|
||||
|
||||
When passing a `FILE*`, a `native_handle` or an io-object with a `native_handle`,
|
||||
the initializer will assign the handle as is to the child process.
|
||||
That is the file descriptor/handle gets cloned into the subprocess and used without modification.
|
||||
|
||||
When passing a filesystem::path, the initializer will attempt to open the file and then pass the handle
|
||||
to the subprocess.
|
||||
|
||||
When passing a `readable_pipe` to stdout/stderr or a `writable_pipe` to stdin by reference,
|
||||
the initializer to create the other side of the pipe (`writable_pipe` for stdout/stderr, `readable_pipe` for `stdin`),
|
||||
connect the pair and pass the native_handle to the child process.
|
||||
|
||||
That is, these two are equivalent:
|
||||
|
||||
.Implicit construction of the readable pipe.
|
||||
[source,cpp]
|
||||
----
|
||||
asio::io_context ctx;
|
||||
asio::writable_pipe wp{ctx};
|
||||
// create a readable pipe internally and connect it to wp
|
||||
process proc{ctx, "/bin/bash", {}, process_stdio{.in=wp}};
|
||||
|
||||
// create it explicitly
|
||||
{
|
||||
// the pipe the child process reads from
|
||||
asio::readable_pipe rp{ctx};
|
||||
asio::connect_pipe(rp, wp);
|
||||
// `rp.native_handle()` will be assigned to the child processes stdin
|
||||
process proc{ctx, "/bin/bash", {}, process_stdio{.in=rp}};
|
||||
rp.close(); // close it so the pipe closes when the `proc exits.
|
||||
}
|
||||
----
|
||||
|
||||
The explicit version allows you to assign the same `writable_pipe` to `stdout` and `stderr`:
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
// the pipe the parent process reads from and both
|
||||
// stderr & stdout of the child process write to
|
||||
asio::readable_pipe rp{ctx};
|
||||
asio::writable_pipe wp{ctx};
|
||||
asio::connect_pipe(rp, wp);
|
||||
process proc{ctx, "/bin/bash", {}, process_stdio{.out=wp, .err=wp}};
|
||||
wp.close(); // close it so the pipe closes when the `proc exits.
|
||||
----
|
||||
|
||||
NOTE: If the child writes to a pipe, the parent reads from it et vice versa.
|
||||
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
/// The initializer for the stdio of a subprocess
|
||||
struct process_stdio
|
||||
{
|
||||
__implementation_defined__ in;
|
||||
__implementation_defined__ out;
|
||||
__implementation_defined__ err;
|
||||
};
|
||||
----
|
||||
27
doc/reference/windows/creation_flags.adoc
Normal file
27
doc/reference/windows/creation_flags.adoc
Normal file
@@ -0,0 +1,27 @@
|
||||
== `windows/creation_flags.hpp`
|
||||
|
||||
Creation flags allows explicitly setting `dwFlags`
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
// An initializer to add to the dwFlags in the startup-info
|
||||
template<DWORD Flags>
|
||||
struct process_creation_flags;
|
||||
|
||||
// A flag to create a new process group. Necessary to allow interrupts for the subprocess.
|
||||
constexpr static process_creation_flags<CREATE_NEW_PROCESS_GROUP> create_new_process_group;
|
||||
|
||||
// Breakaway from the current job object.
|
||||
constexpr static process_creation_flags<CREATE_BREAKAWAY_FROM_JOB> create_breakaway_from_job;
|
||||
// Allocate a new console.
|
||||
constexpr static process_creation_flags<CREATE_NEW_CONSOLE> create_new_console;
|
||||
|
||||
----
|
||||
|
||||
|
||||
The flags can be used like this:
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
process p{"C:\\not-a-virus.exe", {}, process::windows::create_new_console};
|
||||
----
|
||||
32
doc/reference/windows/show_window.adoc
Normal file
32
doc/reference/windows/show_window.adoc
Normal file
@@ -0,0 +1,32 @@
|
||||
== `windows/show_window.hpp`
|
||||
|
||||
Creation flags allows explicitly setting `wShowWindow` options
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
/// A templated initializer to set wShowWindow flags.
|
||||
template<DWORD Flags>
|
||||
struct process_show_window;
|
||||
|
||||
//Hides the window and activates another window.
|
||||
constexpr static process_show_window<SW_HIDE > show_window_hide;
|
||||
//Activates the window and displays it as a maximized window.
|
||||
constexpr static process_show_window<SW_SHOWMAXIMIZED > show_window_maximized;
|
||||
//Activates the window and displays it as a minimized window.
|
||||
constexpr static process_show_window<SW_SHOWMINIMIZED > show_window_minimized;
|
||||
//Displays the window as a minimized window. This value is similar to `minimized`, except the window is not activated.
|
||||
constexpr static process_show_window<SW_SHOWMINNOACTIVE> show_window_minimized_not_active;
|
||||
//Displays a window in its most recent size and position. This value is similar to show_normal`, except that the window is not activated.
|
||||
constexpr static process_show_window<SW_SHOWNOACTIVATE > show_window_not_active;
|
||||
//Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
|
||||
constexpr static process_show_window<SW_SHOWNORMAL > show_window_normal;
|
||||
|
||||
----
|
||||
|
||||
|
||||
The flags can be used like this:
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
process p{"C:\\not-a-virus.exe", {}, process::windows::show_window_minimized};
|
||||
----
|
||||
13
doc/start_dir.adoc
Normal file
13
doc/start_dir.adoc
Normal file
@@ -0,0 +1,13 @@
|
||||
== `process_start_dir`
|
||||
|
||||
The easier initializer to use is `process_start_dir`:
|
||||
|
||||
.example/start_dir.cpp:17-20
|
||||
[source,cpp,indent=0]
|
||||
----
|
||||
include::../example/start_dir.cpp[tag=start_dir]
|
||||
----
|
||||
|
||||
This will run `ls` in the folder `/home` instead of the current folder.
|
||||
|
||||
WARNING: If your path is relative, it may fail on posix, because the directory is changed before a call to execve.
|
||||
65
doc/stdio.adoc
Normal file
65
doc/stdio.adoc
Normal file
@@ -0,0 +1,65 @@
|
||||
= stdio
|
||||
|
||||
When using io with a subprocess, all three standard streams (stdin, stdout, stderr) get set for the child-process.
|
||||
The default setting is to inherit the parent process.
|
||||
|
||||
This feature meant to be flexible, which is why there is little checking on the arguments assigned to one of those streams.
|
||||
|
||||
== Pipes
|
||||
|
||||
asio pipes can be used for io. When using in process_stdio they will get
|
||||
automatically connected and the other side will get assigned to the child process:
|
||||
|
||||
.example/stdio.cpp:20-29
|
||||
[source,cpp,indent=0]
|
||||
----
|
||||
include::../example/stdio.cpp[tag=readable_pipe]
|
||||
----
|
||||
|
||||
readable pipes can be assigned to `out` and `err`, while writable_pipes can be assigned to `in`.
|
||||
|
||||
== `FILE*`
|
||||
|
||||
`FILE*` can also be used for either side; this allows the `stdin`, `stderr`, `stdout` macros to be used:
|
||||
|
||||
.example/stdio.cpp:35-38
|
||||
[source,cpp]
|
||||
----
|
||||
include::../example/stdio.cpp[tag=file]
|
||||
----
|
||||
|
||||
== `nullptr`
|
||||
|
||||
`nullptr` may be used to set a given stream to be opened on the null-device (`/dev/null` on posix, `NUL` on windows).
|
||||
This is used to ignore output or give only EOF as input.
|
||||
|
||||
.example/stdio.cpp:43-46
|
||||
[source,cpp]
|
||||
----
|
||||
include::../example/stdio.cpp[tag=null]
|
||||
----
|
||||
|
||||
== `native_handle`
|
||||
|
||||
A native handle can be used as well, which means an `int` on posix or a `HANDLE` on windows.
|
||||
Furthermore, any object that has a `native_handle` function which returns a valid type for a stdio stream.
|
||||
|
||||
E.g. a domain socket on linux.
|
||||
|
||||
.example/stdio.cpp:52-57
|
||||
[source,cpp]
|
||||
----
|
||||
include::../example/stdio.cpp[tag=native_handle]
|
||||
----
|
||||
|
||||
== popen
|
||||
|
||||
Additionally, process v2 provides a `popen` class.
|
||||
It starts a process and connects pipes for stdin and stdout, so that the popen object can be used as a stream.
|
||||
|
||||
.example/stdio.cpp:63-66
|
||||
[source,cpp]
|
||||
----
|
||||
include::../example/stdio.cpp[tag=popen]
|
||||
----
|
||||
|
||||
426
doc/tutorial.qbk
426
doc/tutorial.qbk
@@ -1,426 +0,0 @@
|
||||
[def bp::system [funcref boost::process::system bp::system]]
|
||||
[def bp::async_system [funcref boost::process::async_system bp::async_system]]
|
||||
[def bp::spawn [funcref boost::process::spawn bp::spawn]]
|
||||
[def bp::child [classref boost::process::child bp::child]]
|
||||
[def bp::cmd [classref boost::process::cmd bp::cmd]]
|
||||
[def bp::group [classref boost::process::group bp::group]]
|
||||
[def bp::ipstream [classref boost::process::ipstream bp::ipstream]]
|
||||
[def bp::opstream [classref boost::process::opstream bp::opstream]]
|
||||
[def bp::pstream [classref boost::process::pstream bp::pstream]]
|
||||
[def bp::pipe [classref boost::process::pipe bp::pipe]]
|
||||
[def bp::async_pipe [classref boost::process::async_pipe bp::async_pipe]]
|
||||
[def bp::search_path [funcref boost::process::search_path bp::search_path]]
|
||||
[def boost_org [@www.boost.org "www.boost.org"]]
|
||||
[def std::system [@http://en.cppreference.com/w/cpp/utility/program/system std::system]]
|
||||
[def child_running [memberref boost::process::child::running running]]
|
||||
[def child_wait [memberref boost::process::child::wait wait]]
|
||||
[def child_wait_for [memberref boost::process::child::wait_for wait_for]]
|
||||
[def child_exit_code [memberref boost::process::child::exit_code exit_code]]
|
||||
[def group_wait_for [memberref boost::process::group::wait_for wait_for]]
|
||||
[def bp::on_exit [globalref boost::process::on_exit bp::on_exit]]
|
||||
[def bp::null [globalref boost::process::null bp::null]]
|
||||
[def child_terminate [memberref boost::process::child::terminate terminate]]
|
||||
[def group_terminate [memberref boost::process::group::terminate terminate]]
|
||||
[def group_wait [memberref boost::process::group::wait wait]]
|
||||
[def bp::std_in [globalref boost::process::std_in bp::std_in]]
|
||||
[def bp::std_out [globalref boost::process::std_out bp::std_out]]
|
||||
[def bp::std_err [globalref boost::process::std_err bp::std_err]]
|
||||
[def io_service [@http://www.boost.org/doc/libs/release/doc/html/boost_asio/reference/io_service.html boost::asio::io_service]]
|
||||
[def asio_buffer [@http://www.boost.org/doc/libs/release/doc/html/boost_asio/reference/buffer.html boost::asio::buffer]]
|
||||
[def asio_async_read [@http://www.boost.org/doc/libs/release/doc/html/boost_asio/reference/async_read.html boost::asio::async_read]]
|
||||
[def bp::environment [classref boost::process::basic_environment bp::environment]]
|
||||
[def bp::native_environment [classref boost::process::basic_native_environment bp::native_environment]]
|
||||
[def boost::this_process::environment [funcref boost::this_process::environment boost::this_process::environment]]
|
||||
[def std::chrono::seconds [@http://en.cppreference.com/w/cpp/chrono/duration std::chrono::seconds]]
|
||||
[def std::vector [@http://en.cppreference.com/w/cpp/container/vector std::vector]]
|
||||
|
||||
[def __wait_for__ [memberref boost::process::child::wait_for wait_for]]
|
||||
[def __wait_until__ [memberref boost::process::child::wait_until wait_until]]
|
||||
[def __detach__ [memberref boost::process::child::detach detach]]
|
||||
|
||||
[def __reference__ [link process.reference reference]]
|
||||
[def __concepts__ [link boost_process.concepts concepts]]
|
||||
|
||||
[def boost::asio::yield_context [@http://www.boost.org/doc/libs/release/doc/html/boost_asio/reference/yield_context.html boost::asio::yield_context]]
|
||||
[def boost::asio::coroutine [@http://www.boost.org/doc/libs/release/doc/html/boost_asio/reference/coroutine.html boost::asio::coroutine]]
|
||||
[def bp::env [globalref boost::process::env bp::env]]
|
||||
|
||||
[section:tutorial Tutorial]
|
||||
|
||||
In this section we will go step by step through the different features of
|
||||
boost.process. For a full description see the __reference__ and the __concepts__ sections.
|
||||
|
||||
[section Starting a process]
|
||||
|
||||
We want to start a process, so let's start with a simple process. We will
|
||||
invoke the gcc compiler to compile a simple program.
|
||||
|
||||
With the standard library this looks like this.
|
||||
|
||||
```
|
||||
int result = std::system("g++ main.cpp");
|
||||
```
|
||||
|
||||
Which we can write exactly like this in boost.process.
|
||||
|
||||
```
|
||||
namespace bp = boost::process; //we will assume this for all further examples
|
||||
int result = bp::system("g++ main.cpp");
|
||||
```
|
||||
|
||||
If a single string (or the explicit form bp::cmd), it will be interpreted as a command line.
|
||||
That will cause the execution function to search the `PATH` variable to find the executable.
|
||||
The alternative is the `exe-args` style, where the first string will be interpreted as a filename (including the path),
|
||||
and the rest as arguments passed to said function.
|
||||
|
||||
[note For more details on the `cmd`/`exe-args` style look [link boost_process.design.arg_cmd_style here]]
|
||||
|
||||
So as a first step, we'll use the `exe-args` style.
|
||||
|
||||
```
|
||||
int result = bp::system("/usr/bin/g++", "main.cpp");
|
||||
```
|
||||
|
||||
With that syntax we still have "g++" hard-coded, so let's assume we get the string
|
||||
from an external source as `boost::filesystem::path`, we can do this too.
|
||||
|
||||
```
|
||||
boost::filesystem::path p = "/usr/bin/g++"; //or get it from somewhere else.
|
||||
int result = bp::system(p, "main.cpp");
|
||||
```
|
||||
|
||||
Now we might want to find the `g++` executable in the `PATH`-variable, as the `cmd` syntax would do.
|
||||
`Boost.process` provides a function to this end: bp::search_path.
|
||||
|
||||
```
|
||||
boost::filesystem::path p = bp::search_path("g++"); //or get it from somewhere else.
|
||||
int result = bp::system(p, "main.cpp");
|
||||
```
|
||||
|
||||
[note [funcref boost::process::search_path search_path] will search for any executable with that name.
|
||||
This also includes to add a file suffix on windows, such as `.exe` or `.bat`.]
|
||||
|
||||
[endsect]
|
||||
|
||||
[section:launch_mode Launch functions]
|
||||
|
||||
Given that our example used the [funcref boost::process::system system] function,
|
||||
our program will wait until the child process is completed. This may be unwanted,
|
||||
especially since compiling can take a while.
|
||||
|
||||
In order to avoid that, boost.process provides several ways to launch a process.
|
||||
Besides the already mentioned [funcref boost::process::system system] function and its
|
||||
asynchronous version [funcref boost::process::async_system async_system],
|
||||
we can also use the [funcref boost::process::spawn spawn] function or the
|
||||
[classref boost::process::child child] class.
|
||||
|
||||
The [funcref boost::process::spawn spawn] function launches a process and
|
||||
immediately detaches it, so no handle will be returned and the process will be ignored.
|
||||
This is not what we need for compiling, but maybe we want to entertain the user,
|
||||
while compiling:
|
||||
|
||||
```
|
||||
bp::spawn(bp::search_path("chrome"), boost_org);
|
||||
```
|
||||
|
||||
Now for the more sensible approach for compiling: a non-blocking execution.
|
||||
To implement that, we directly call the constructor of [classref boost::process::child child].
|
||||
|
||||
```
|
||||
bp::child c(bp::search_path("g++"), "main.cpp");
|
||||
|
||||
while (c.child_running())
|
||||
do_some_stuff();
|
||||
|
||||
c.child_wait(); //wait for the process to exit
|
||||
int result = c.child_exit_code();
|
||||
```
|
||||
|
||||
So we launch the process, by calling the child constructor. Then we check and do other
|
||||
things while the process is running and afterwards get the exit code. The call
|
||||
to child_wait is necessary, to obtain it and tell the operating system, that no
|
||||
one is waiting for the process anymore.
|
||||
|
||||
[note You can also wait for a time span or a until a time point with __wait_for__ and __wait_until__]
|
||||
|
||||
[warning If you don't call wait on a child object, it will be terminated on destruction.
|
||||
This can be avoided by calling __detach__ beforehand]
|
||||
|
||||
[endsect]
|
||||
[section:error_handling Error]
|
||||
|
||||
Until now, we have assumed that everything works out, but it is not impossible,
|
||||
that "g++" is not present. That will cause the launch of the process to fail.
|
||||
The default behaviour of all functions is to throw a
|
||||
[@http://en.cppreference.com/w/cpp/error/system_error std::system_error] on failure.
|
||||
As with many other functions in this library, passing an [@http://en.cppreference.com/w/cpp/error/error_code std::error_code]
|
||||
will change the behaviour, so that instead of throwing an exception, the error will be assigned to the error code.
|
||||
|
||||
```
|
||||
std::error_code ec;
|
||||
bp::system("g++ main.cpp", ec);
|
||||
```
|
||||
[endsect]
|
||||
[section:io Synchronous I/O]
|
||||
|
||||
In the examples given above, we have only started a program, but did not consider the output.
|
||||
The default depends on the system, but usually this will just write it to the same output as the launching process.
|
||||
If this shall be guaranteed, the streams can be explicitly forwarded like this.
|
||||
|
||||
```
|
||||
bp::system("g++ main.cpp", bp::std_out > stdout, bp::std_err > stderr, bp::std_in < stdin);
|
||||
```
|
||||
|
||||
Now for the first example, we might want to just ignore the output, which can be done by redirecting it to the null-device.
|
||||
This can be achieved this way:
|
||||
|
||||
```
|
||||
bp::system("g++ main.cpp", bp::std_out > bp::null);
|
||||
```
|
||||
|
||||
Alternatively we can also easily redirect the output to a file:
|
||||
|
||||
```
|
||||
bp::system("g++ main.cpp", bp::std_out > "gcc_out.log");
|
||||
```
|
||||
|
||||
Now, let's take a more visual example for reading data.
|
||||
[@http://pubs.opengroup.org/onlinepubs/009696699/utilities/nm.html nm] is a tool on posix,
|
||||
which reads the outline, i.e. a list of all entry points, of a binary.
|
||||
Every entry point will be put into a single line, and we will use a pipe to read it.
|
||||
At the end an empty line is appended, which we use as the indication to stop reading.
|
||||
Boost.process provides the pipestream ([classref boost::process::ipstream ipstream],
|
||||
[classref boost::process::opstream opstream], [classref boost::process::pstream pstream]) to
|
||||
wrap around the [classref boost::process::pipe pipe] and provide an implementation of the
|
||||
[@http://en.cppreference.com/w/cpp/io/basic_istream std::istream],
|
||||
[@http://en.cppreference.com/w/cpp/io/basic_ostream std::ostream] and
|
||||
[@http://en.cppreference.com/w/cpp/io/basic_iostream std::iostream] interface.
|
||||
|
||||
```
|
||||
std::vector<std::string> read_outline(std::string & file)
|
||||
{
|
||||
bp::ipstream is; //reading pipe-stream
|
||||
bp::child c(bp::search_path("nm"), file, bp::std_out > is);
|
||||
|
||||
std::vector<std::string> data;
|
||||
std::string line;
|
||||
|
||||
while (c.child_running() && std::getline(is, line) && !line.empty())
|
||||
data.push_back(line);
|
||||
|
||||
c.child_wait();
|
||||
|
||||
return data;
|
||||
}
|
||||
```
|
||||
|
||||
What this does is redirect the `stdout` of the process into a pipe and we read this
|
||||
synchronously.
|
||||
|
||||
[warning The pipe will cause a deadlock if you try to read after nm exited]
|
||||
[note You can do the same thing with [globalref boost::process::std_err std_err]]
|
||||
|
||||
Now we get the name from `nm` and we might want to demangle it, so we use input and output.
|
||||
`nm` has a demangle option, but for the sake of the example, we'll use
|
||||
[@https://sourceware.org/binutils/docs/binutils/c_002b_002bfilt.html c++filt] for this.
|
||||
|
||||
```
|
||||
bp::opstream in;
|
||||
bp::ipstream out;
|
||||
|
||||
bp::child c("c++filt", std_out > out, std_in < in);
|
||||
|
||||
in << "_ZN5boost7process8tutorialE" << endl;
|
||||
std::string value;
|
||||
out >> value;
|
||||
|
||||
c.child_terminate();
|
||||
```
|
||||
|
||||
Now you might want to forward output from one process to another processes input.
|
||||
|
||||
```
|
||||
std::vector<std::string> read_demangled_outline(const std::string & file)
|
||||
{
|
||||
bp::pipe p;
|
||||
bp::ipstream is;
|
||||
|
||||
std::vector<std::string> outline;
|
||||
|
||||
//we just use the same pipe, so the
|
||||
bp::child nm(bp::search_path("nm"), file, bp::std_out > p);
|
||||
bp::child filt(bp::search_path("c++filt"), bp::std_in < p, bp::std_out > is);
|
||||
|
||||
std::string line;
|
||||
while (filt.running() && std::getline(is, line)) //when nm finished the pipe closes and c++filt exits
|
||||
outline.push_back(line);
|
||||
|
||||
nm.child_wait();
|
||||
filt.wait();
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
This forwards the data from `nm` to `c++filt` without your process needing to do anything.
|
||||
|
||||
[endsect]
|
||||
[section:async_io Asynchronous I/O]
|
||||
|
||||
Boost.process allows the usage of boost.asio to implement asynchronous I/O.
|
||||
If you are familiar with [@http://www.boost.org/doc/libs/release/libs/asio/ boost.asio] (which we highly recommend),
|
||||
you can use [classref boost::process::async_pipe async_pipe] which is implemented
|
||||
as an I/O-Object and can be used like [classref boost::process::pipe pipe] as shown above.
|
||||
|
||||
Now we get back to our compiling example. `nm` we might analyze it line by line,
|
||||
but the compiler output will just be put into one large buffer.
|
||||
|
||||
With [@http://www.boost.org/doc/libs/release/libs/asio/ boost.asio] this is what it looks like.
|
||||
|
||||
```
|
||||
io_service ios;
|
||||
std::vector<char> buf(4096);
|
||||
|
||||
bp::async_pipe ap(ios);
|
||||
|
||||
bp::child c(bp::search_path("g++"), "main.cpp", bp::std_out > ap);
|
||||
|
||||
asio_async_read(ap, asio_buffer(buf),
|
||||
[](const boost::system::error_code &ec, std::size_t size){});
|
||||
|
||||
ios.run();
|
||||
int result = c.exit_code();
|
||||
```
|
||||
|
||||
To make it easier, boost.process provides simpler interface for that, so that the buffer can be passed directly,
|
||||
provided we also pass a reference to an io_service.
|
||||
|
||||
```
|
||||
io_service ios;
|
||||
std::vector<char> buf(4096);
|
||||
|
||||
bp::child c(bp::search_path("g++"), "main.cpp", bp::std_out > asio_buffer(buf), ios);
|
||||
|
||||
ios.run();
|
||||
int result = c.exit_code();
|
||||
```
|
||||
|
||||
[note Passing an instance of io_service to the launching function automatically cause it to wait asynchronously for the exit, so no call of
|
||||
[memberref boost::process::child::wait wait] is needed]
|
||||
|
||||
To make it even easier, you can use [@http://en.cppreference.com/w/cpp/thread/future std::future] for asynchronous operations
|
||||
(you will still need to pass a reference to a io_service) to the launching function, unless you use bp::system or bp::async_system.
|
||||
|
||||
Now we will revisit our first example and read the compiler output asynchronously:
|
||||
|
||||
```
|
||||
boost::asio::io_service ios;
|
||||
|
||||
std::future<std::string> data;
|
||||
|
||||
child c("g++", "main.cpp", //set the input
|
||||
bp::std_in.close(),
|
||||
bp::std_out > bp::null, //so it can be written without anything
|
||||
bp::std_err > data,
|
||||
ios);
|
||||
|
||||
|
||||
ios.run(); //this will actually block until the compiler is finished
|
||||
|
||||
auto err = data.get();
|
||||
```
|
||||
|
||||
[endsect]
|
||||
[section:group Groups]
|
||||
|
||||
When launching several processes, processes can be grouped together.
|
||||
This will also apply for a child process, that launches other processes,
|
||||
if they do not modify the group membership. E.g. if you call `make` which
|
||||
launches other processes and call terminate on it,
|
||||
it will not terminate all the child processes of the child unless you use a group.
|
||||
|
||||
The two main reasons to use groups are:
|
||||
|
||||
# Being able to terminate child processes of the child process
|
||||
# Grouping several processes into one, just so they can be terminated at once
|
||||
|
||||
If we have program like `make`, which does launch its own child processes,
|
||||
a call of child_terminate might not suffice. I.e. if we have a makefile launching `gcc`
|
||||
and use the following code, the `gcc` process will still run afterwards:
|
||||
|
||||
```
|
||||
bp::child c("make");
|
||||
if (!c.child_wait_for(std::chrono::seconds(10)) //give it 10 seconds
|
||||
c.child_terminate(); //then terminate
|
||||
```
|
||||
|
||||
So in order to also terminate `gcc` we can use a group.
|
||||
|
||||
```
|
||||
bp::group g;
|
||||
bp::child c("make", g);
|
||||
if (!g.group_wait_for(std::chrono::seconds(10))
|
||||
g.group_terminate();
|
||||
|
||||
c.child_wait(); //to avoid a zombie process & get the exit code
|
||||
```
|
||||
|
||||
Now given the example, we still call child_wait to avoid a zombie process.
|
||||
An easier solution for that might be to use [funcref boost::process::spawn spawn].
|
||||
|
||||
|
||||
To put two processes into one group, the following code suffices. Spawn already
|
||||
launches a detached process (i.e. without a child-handle), but they can be grouped,
|
||||
to that in the case of a problem, RAII is still a given.
|
||||
|
||||
```
|
||||
void f()
|
||||
{
|
||||
bp::group g;
|
||||
bp::spawn("foo", g);
|
||||
bp::spawn("bar", g);
|
||||
|
||||
do_something();
|
||||
|
||||
g.group_wait();
|
||||
};
|
||||
```
|
||||
|
||||
In the example, it will wait for both processes at the end of the function unless
|
||||
an exception occurs. I.e. if an exception is thrown, the group will be terminated.
|
||||
|
||||
|
||||
Please see the [headerref boost/process/group.hpp reference] for more information.
|
||||
|
||||
[endsect]
|
||||
[section:env Environment]
|
||||
|
||||
This library provides access to the environment of the current process and allows
|
||||
setting it for the child process.
|
||||
|
||||
```
|
||||
//get a handle to the current environment
|
||||
auto env = boost::this_process::environment();
|
||||
//add a variable to the current environment
|
||||
env["VALUE_1"] = "foo";
|
||||
|
||||
//copy it into an environment separate to the one of this process
|
||||
bp::environment env_ = env;
|
||||
//append two values to a variable in the new env
|
||||
env_["VALUE_2"] += {"bar1", "bar2"};
|
||||
|
||||
//launch a process with `env_`
|
||||
bp::system("stuff", env_);
|
||||
```
|
||||
|
||||
A more convenient way to modify the environment for the child is the
|
||||
[globalref boost::process::env env] property, which the example as following:
|
||||
|
||||
```
|
||||
bp::system("stuff", bp::env["VALUE_1"]="foo", bp::env["VALUE_2"]+={"bar1", "bar2"});
|
||||
|
||||
```
|
||||
|
||||
Please see to the [headerref boost/process/environment.hpp reference] for more information.
|
||||
|
||||
[endsect]
|
||||
[endsect]
|
||||
81
doc/version2.adoc
Normal file
81
doc/version2.adoc
Normal file
@@ -0,0 +1,81 @@
|
||||
= Version 2
|
||||
|
||||
Boost.process V2 is an redesign of boost.process, based on previous
|
||||
design mistakes & improved system APIs.
|
||||
|
||||
The major changes are
|
||||
|
||||
* Simplified interface
|
||||
* Reliance on pidfd_open on linux
|
||||
* Full asio integration
|
||||
* Removed unreliable functionality
|
||||
* UTF8 Support
|
||||
* separate compilation
|
||||
* fd safe by default
|
||||
|
||||
Version 2 is now the default. In order to discourage usage of the deprecated v1, it's documentation has been removed.
|
||||
|
||||
== Simplified Interface
|
||||
|
||||
In process v1 one can define partial settings in the constructor of the process,
|
||||
which has lead to a small DSL.
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
child c{exe="test", args+="--help", std_in < null(), env["FOO"] += "BAR"};
|
||||
----
|
||||
|
||||
While this looks fancy at first, it really does not scale well with more parameters.
|
||||
For process v2, the interfaces is simple:
|
||||
|
||||
[source,cpp]
|
||||
----
|
||||
extern std::unordered_map<std::string, std::string> my_env;
|
||||
extern asio::io_context ctx;
|
||||
process proc(ctx, "./test", {"--help"}, process_stdio{nullptr, {}, {}}, process_environment(my_env));
|
||||
----
|
||||
|
||||
Every initializer addresses one logical component (e.g. stdio) instead of multiple ones accumulating.
|
||||
Furthermore, every process has a path and arguments, instead of a confusing mixture of cmd-style and
|
||||
exe-args that can be randomly spread out.
|
||||
|
||||
|
||||
== `pidfd_open`
|
||||
|
||||
Since process v1 came out, linux has moved along and added [pidfd_open](https://man7.org/linux/man-pages/man2/pidfd_open.2.html)
|
||||
which allows users to obtain a descriptor for a process.
|
||||
This is much more reliable since it is not as easy to miss as a `SIGCHLD`.
|
||||
Windows has provided `HANDLE`s for processes all along.
|
||||
Unless the OS doesn't support it, process v2 will use file descriptors and handles to implement waiting
|
||||
for processes.
|
||||
|
||||
== Full asio integration
|
||||
|
||||
Process v1 aimed to make asio optional, but synchronous IO with subprocesses usually means one is begging
|
||||
for deadlocks.
|
||||
Since asio added pipes in boost 1.78, boost process V2 is fully asio based and uses it's pipes and
|
||||
file-handles for the subprocess.
|
||||
|
||||
== Unreliable functionality
|
||||
|
||||
Certain parts of boost.process were not as reliable as they should've been.
|
||||
|
||||
This concerns especially the `wait_for` and `wait_until` functions on the process.
|
||||
The latter are easy to do on windows, but posix does not provide an API for this.
|
||||
Thus the wait_for used signals or fork, which was all but safe.
|
||||
Since process v2 is based on asio and thus supports cancellation,
|
||||
a wait_for can now safely be implemented with an async_wait + timeout.
|
||||
|
||||
== UTF-8
|
||||
|
||||
Instead of using ascii-APIs on windows, process V2 just assumes UTF-8 everywhere
|
||||
and uses the UTF-16 APIs.
|
||||
|
||||
== Fd safe by default
|
||||
|
||||
While not a problem on windows (since HANDLEs get manually enabled for inheritance),
|
||||
posix systems create a problem with inheriting file handles by default.
|
||||
|
||||
Process V2 will automatically close all non-whitelisted descriptors,
|
||||
without needing any option to enable it.
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
<?xml version="1.0" standalone="yes"?>
|
||||
<programlisting>
|
||||
for (auto & s : seq)
|
||||
s.<methodname alt="boost::process::extend::handler::on_setup">on_setup</methodname>(*this);
|
||||
|
||||
if (<methodname alt="boost::process::extend::windows_executor::error">error</methodname>())
|
||||
{
|
||||
for (auto & s : seq)
|
||||
s.<methodname alt="boost::process::extend::handler::on_error">on_error</methodname>(*this, <methodname alt="boost::process::extend::windows_executor::error">error</methodname>());
|
||||
return <classname alt="boost::process::child">child</classname>();
|
||||
}
|
||||
int err_code = <ulink url="https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425.aspx">CreateProcess</ulink>(
|
||||
exe,
|
||||
cmd_line,
|
||||
proc_attrs,
|
||||
thread_attrs,
|
||||
creation_flags,
|
||||
env,
|
||||
work_dir,
|
||||
startup_info,
|
||||
proc_info);
|
||||
|
||||
<classname alt="boost::process::child">child</classname> c(proc_info, exit_code);
|
||||
|
||||
if (<methodname alt="boost::process::extend::windows_executor::error">error</methodname>())
|
||||
for (auto & s : seq)
|
||||
s.<methodname alt="boost::process::extend::handler::on_error">on_error</methodname>(*this, <methodname alt="boost::process::extend::windows_executor::error">error</methodname>());
|
||||
else
|
||||
for (auto & s : seq)
|
||||
s.<methodname alt="boost::process::extend::handler::on_error">on_success</methodname>(*this);
|
||||
|
||||
//now we check again, because a on_success handler might've errored.
|
||||
if (<methodname alt="boost::process::extend::windows_executor::error">error</methodname>())
|
||||
{
|
||||
for (auto & s : seq)
|
||||
s.<methodname alt="boost::process::extend::handler::on_error">on_error</methodname>(*this, <methodname alt="boost::process::extend::windows_executor::error">error</methodname>());
|
||||
return <classname alt="boost::process::child">child</classname>();
|
||||
}
|
||||
else
|
||||
return c;
|
||||
|
||||
</programlisting>
|
||||
@@ -1,28 +1,19 @@
|
||||
# Copyright (c) 2006, 2007 Julio M. Merino Vidal
|
||||
# Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
|
||||
# Copyright (c) 2009 Boris Schaeling
|
||||
# Copyright (c) 2010 Felipe Tanus, Boris Schaeling
|
||||
# Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
|
||||
# Copyright (c) 2022 Klemens Morgenstern
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
project : requirements
|
||||
<include>../../..
|
||||
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS
|
||||
<target-os>windows:<define>WIN32_LEAN_AND_MEAN
|
||||
<link>static
|
||||
;
|
||||
|
||||
import testing ;
|
||||
|
||||
compile args.cpp ;
|
||||
compile async_io.cpp ;
|
||||
compile env.cpp ;
|
||||
compile error_handling.cpp ;
|
||||
compile io.cpp ;
|
||||
compile posix.cpp : <build>no <target-os>linux:<build>yes ;
|
||||
compile start_dir.cpp ;
|
||||
compile sync_io.cpp ;
|
||||
compile terminate.cpp ;
|
||||
compile wait.cpp ;
|
||||
compile windows.cpp : <build>no <target-os>windows:<build>yes ;
|
||||
exe intro : intro.cpp /boost//process : <boost.process.fs>boost ;
|
||||
exe intro_popen : intro_popen.cpp /boost//process : <boost.process.fs>boost ;
|
||||
exe quickstart : quickstart.cpp /boost//process : <boost.process.fs>boost ;
|
||||
exe env : env.cpp /boost//process : <boost.process.fs>boost ;
|
||||
exe start_dir : start_dir.cpp /boost//process : <boost.process.fs>boost ;
|
||||
exe stdio : stdio.cpp /boost//process : <boost.process.fs>boost ;
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
|
||||
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
|
||||
// Copyright (c) 2009 Boris Schaeling
|
||||
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
|
||||
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/process.hpp>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace bp = boost::process;
|
||||
|
||||
int main()
|
||||
{
|
||||
bp::child c("test.exe", "--foo", "/bar");
|
||||
|
||||
//or explicit
|
||||
|
||||
bp::child c2(
|
||||
bp::exe="test.exe",
|
||||
bp::args={"--foo", "/bar"}
|
||||
);
|
||||
|
||||
c.wait();
|
||||
c2.wait();
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
|
||||
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
|
||||
// Copyright (c) 2009 Boris Schaeling
|
||||
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
|
||||
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/process.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace bp = boost::process;
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::asio::io_context ios;
|
||||
boost::asio::streambuf buffer;
|
||||
|
||||
|
||||
bp::child c(
|
||||
"test.exe",
|
||||
bp::std_out > buffer,
|
||||
ios
|
||||
);
|
||||
|
||||
ios.run();
|
||||
}
|
||||
@@ -8,17 +8,64 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/process.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace bp = boost::process;
|
||||
using namespace boost::process;
|
||||
namespace asio = boost::asio;
|
||||
|
||||
int main()
|
||||
{
|
||||
bp::environment my_env = boost::this_process::environment();
|
||||
{ // tag::current_env[]
|
||||
// search in the current environment
|
||||
auto exe = environment::find_executable("g++");
|
||||
|
||||
my_env["PATH"] += "/foo";
|
||||
bp::system("test.exe", my_env);
|
||||
std::unordered_map <environment::key, environment::value> my_env =
|
||||
{
|
||||
{"SECRET", "THIS_IS_A_TEST"},
|
||||
{"PATH", {"/bin", "/usr/bin"}}
|
||||
};
|
||||
|
||||
auto other_exe = environment::find_executable("g++", my_env);
|
||||
//end::current_env[]
|
||||
}
|
||||
|
||||
{
|
||||
// tag::subprocess_env[]
|
||||
asio::io_context ctx;
|
||||
std::unordered_map<environment::key, environment::value> my_env =
|
||||
{
|
||||
{"SECRET", "THIS_IS_A_TEST"},
|
||||
{"PATH", {"/bin", "/usr/bin"}}
|
||||
};
|
||||
auto exe = environment::find_executable("g++", my_env);
|
||||
process proc(ctx, exe, {"main.cpp"}, process_environment(my_env));
|
||||
process pro2(ctx, exe, {"test.cpp"}, process_environment(my_env));
|
||||
// end::subprocess_env[]
|
||||
}
|
||||
|
||||
bp::system("test.exe", bp::env["PATH"]+="/bar");
|
||||
{
|
||||
// tag::vector_env[]
|
||||
asio::io_context ctx;
|
||||
auto c = environment::current();
|
||||
// we need to use a value, since windows needs wchar_t.
|
||||
std::vector<environment::key_value_pair> my_env{c.begin(), c.end()};
|
||||
my_env.push_back("SECRET=THIS_IS_A_TEST");
|
||||
auto exe = environment::find_executable("g++", my_env);
|
||||
process proc(ctx, exe, {"main.cpp"}, process_environment(my_env));
|
||||
// end::vector_env[]
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
// tag::map_env[]
|
||||
asio::io_context ctx;
|
||||
std::unordered_map<environment::key, environment::value> my_env;
|
||||
for (const auto & kv : environment::current())
|
||||
if (kv.key().string() != "SECRET")
|
||||
my_env[kv.key()] = kv.value();
|
||||
|
||||
auto exe = environment::find_executable("g++", my_env);
|
||||
process proc(ctx, exe, {"main.cpp"}, process_environment(my_env));
|
||||
// end::map_env[]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
|
||||
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
|
||||
// Copyright (c) 2009 Boris Schaeling
|
||||
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
|
||||
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/process.hpp>
|
||||
#include <system_error>
|
||||
|
||||
namespace bp = boost::process;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
std::error_code ec;
|
||||
bp::child c1("test.exe", ec);
|
||||
|
||||
|
||||
bp::child c2("test.exe", bp::ignore_error);
|
||||
|
||||
}
|
||||
@@ -1,8 +1,4 @@
|
||||
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
|
||||
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
|
||||
// Copyright (c) 2009 Boris Schaeling
|
||||
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
|
||||
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
|
||||
// Copyright (c) 2022 Klemens Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
@@ -10,18 +6,35 @@
|
||||
//[intro
|
||||
#include <boost/process.hpp>
|
||||
|
||||
using namespace boost::process;
|
||||
#include <boost/asio/read.hpp>
|
||||
#include <boost/asio/readable_pipe.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
namespace proc = boost::process;
|
||||
namespace asio = boost::asio;
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
ipstream pipe_stream;
|
||||
child c("gcc --version", std_out > pipe_stream);
|
||||
asio::io_context ctx;
|
||||
asio::readable_pipe p{ctx};
|
||||
|
||||
const auto exe = proc::environment::find_executable("gcc");
|
||||
|
||||
proc::process c{ctx, exe, {"--version"}, proc::process_stdio{nullptr, p}};
|
||||
|
||||
std::string line;
|
||||
boost::system::error_code ec;
|
||||
|
||||
while (pipe_stream && std::getline(pipe_stream, line) && !line.empty())
|
||||
std::cerr << line << std::endl;
|
||||
auto sz = asio::read(p, asio::dynamic_buffer(line), ec);
|
||||
assert(ec == asio::error::eof);
|
||||
|
||||
std::cout << "Gcc version: '" << line << "'" << std::endl;
|
||||
|
||||
c.wait();
|
||||
return c.exit_code();
|
||||
}
|
||||
//]
|
||||
|
||||
41
example/intro_popen.cpp
Normal file
41
example/intro_popen.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright (c) 2022Klemens Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
|
||||
//[intro
|
||||
#include <boost/process.hpp>
|
||||
|
||||
#include <boost/asio/read.hpp>
|
||||
#include <boost/asio/readable_pipe.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
namespace proc = boost::process;
|
||||
namespace asio = boost::asio;
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
asio::io_context ctx;
|
||||
const auto exe = proc::environment::find_executable("gcc");
|
||||
proc::popen c{ctx, exe, {"--version"}};
|
||||
|
||||
std::string line;
|
||||
boost::system::error_code ec;
|
||||
|
||||
auto sz = asio::read(c, asio::dynamic_buffer(line), ec);
|
||||
assert(ec == asio::error::eof);
|
||||
|
||||
boost::ignore_unused(sz);
|
||||
|
||||
std::cout << "Gcc version: '" << line << "'" << std::endl;
|
||||
|
||||
c.wait();
|
||||
return c.exit_code();
|
||||
}
|
||||
//]
|
||||
@@ -1,91 +0,0 @@
|
||||
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
|
||||
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
|
||||
// Copyright (c) 2009 Boris Schaeling
|
||||
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
|
||||
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/process.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace bp = boost::process;
|
||||
|
||||
int main()
|
||||
{
|
||||
//
|
||||
bp::system(
|
||||
"test.exe",
|
||||
bp::std_out > stdout, //forward
|
||||
bp::std_err.close(), //close
|
||||
bp::std_in < bp::null //null in
|
||||
);
|
||||
|
||||
boost::filesystem::path p = "input.txt";
|
||||
|
||||
bp::system(
|
||||
"test.exe",
|
||||
(bp::std_out & bp::std_err) > "output.txt", //redirect both to one file
|
||||
bp::std_in < p //read input from file
|
||||
);
|
||||
|
||||
{
|
||||
bp::opstream p1;
|
||||
bp::ipstream p2;
|
||||
bp::system(
|
||||
"test.exe",
|
||||
bp::std_out > p2,
|
||||
bp::std_in < p1
|
||||
);
|
||||
p1 << "my_text";
|
||||
int i = 0;
|
||||
p2 >> i;
|
||||
|
||||
}
|
||||
{
|
||||
boost::asio::io_context io_context;
|
||||
bp::async_pipe p1(io_context);
|
||||
bp::async_pipe p2(io_context);
|
||||
bp::system(
|
||||
"test.exe",
|
||||
bp::std_out > p2,
|
||||
bp::std_in < p1,
|
||||
io_context,
|
||||
bp::on_exit([&](int exit, const std::error_code& ec_in)
|
||||
{
|
||||
p1.async_close();
|
||||
p2.async_close();
|
||||
})
|
||||
);
|
||||
std::vector<char> in_buf;
|
||||
std::string value = "my_string";
|
||||
boost::asio::async_write(p1, boost::asio::buffer(value), []( const boost::system::error_code&, std::size_t){});
|
||||
boost::asio::async_read (p2, boost::asio::buffer(in_buf), []( const boost::system::error_code&, std::size_t){});
|
||||
}
|
||||
{
|
||||
boost::asio::io_context io_context;
|
||||
std::vector<char> in_buf;
|
||||
std::string value = "my_string";
|
||||
bp::system(
|
||||
"test.exe",
|
||||
bp::std_out > bp::buffer(in_buf),
|
||||
bp::std_in < bp::buffer(value)
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
boost::asio::io_context io_context;
|
||||
std::future<std::vector<char>> in_buf;
|
||||
std::future<void> write_fut;
|
||||
std::string value = "my_string";
|
||||
bp::system(
|
||||
"test.exe",
|
||||
bp::std_out > in_buf,
|
||||
bp::std_in < bp::buffer(value) > write_fut
|
||||
);
|
||||
|
||||
write_fut.get();
|
||||
in_buf.get();
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
|
||||
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
|
||||
// Copyright (c) 2009 Boris Schaeling
|
||||
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
|
||||
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/process.hpp>
|
||||
#include <boost/process/posix.hpp>
|
||||
#include <boost/process/extend.hpp>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
namespace bp = boost::process;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
//duplicate our pipe descriptor into literal position 4
|
||||
bp::pipe p;
|
||||
bp::system("test", bp::posix::fd.bind(4, p.native_sink()));
|
||||
|
||||
|
||||
//close file-descriptor from explicit integral value
|
||||
bp::system("test", bp::posix::fd.close(STDIN_FILENO));
|
||||
|
||||
//close file-descriptors from explicit integral values
|
||||
bp::system("test", bp::posix::fd.close({STDIN_FILENO, STDOUT_FILENO}));
|
||||
|
||||
//add custom handlers
|
||||
const char *env[2] = { 0 };
|
||||
env[0] = "LANG=de";
|
||||
bp::system("test",
|
||||
bp::extend::on_setup([env](auto &e) { e.env = const_cast<char**>(env); }),
|
||||
bp::extend::on_fork_error([](auto&, const std::error_code & ec)
|
||||
{ std::cerr << errno << std::endl; }),
|
||||
bp::extend::on_exec_setup([](auto&)
|
||||
{ ::chroot("/new/root/directory/"); }),
|
||||
bp::extend::on_exec_error([](auto&, const std::error_code & ec)
|
||||
{ std::ofstream ofs("log.txt"); if (ofs) ofs << errno; })
|
||||
);
|
||||
|
||||
}
|
||||
63
example/quickstart.cpp
Normal file
63
example/quickstart.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#include <boost/process.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
namespace asio = boost::asio;
|
||||
using boost::process::process;
|
||||
|
||||
|
||||
int main(int /*argv*/, char ** /*argv*/)
|
||||
{
|
||||
asio::io_context ctx;
|
||||
{
|
||||
//tag::cp[]
|
||||
// process(asio::any_io_executor, filesystem::path, range<string> args, AdditionalInitializers...)
|
||||
process proc(ctx.get_executor(), // <1>
|
||||
"/usr/bin/cp", // <2>
|
||||
{"source.txt", "target.txt"} // <3>
|
||||
); // <4>
|
||||
//end::cp[]
|
||||
}
|
||||
{
|
||||
//tag::ls[]
|
||||
process proc(ctx, "/bin/ls", {});
|
||||
assert(proc.wait() == 0);
|
||||
//end::ls[]
|
||||
}
|
||||
{
|
||||
//tag::terminate[]
|
||||
process proc(ctx, "/bin/totally-not-a-virus", {});
|
||||
proc.terminate();
|
||||
//end::terminate[]
|
||||
}
|
||||
{
|
||||
//tag::request_exit[]
|
||||
process proc(ctx, "/bin/bash", {});
|
||||
proc.request_exit();
|
||||
proc.wait();
|
||||
//end::request_exit[]
|
||||
}
|
||||
{
|
||||
//tag::interrupt[]
|
||||
process proc(ctx, "/usr/bin/addr2line", {});
|
||||
proc.interrupt();
|
||||
proc.wait();
|
||||
//end::interrupt[]
|
||||
}
|
||||
{
|
||||
//tag::execute[]
|
||||
assert(execute(process(ctx, "/bin/ls", {})) == 0);
|
||||
//end::execute[]
|
||||
}
|
||||
{
|
||||
//tag::async_execute[]
|
||||
async_execute(process(ctx, "/usr/bin/g++", {"hello_world.cpp"}))
|
||||
(asio::cancel_after(std::chrono::seconds(10), asio::cancellation_type::partial)) // <1>
|
||||
(asio::cancel_after(std::chrono::seconds(10), asio::cancellation_type::terminal)) //<2>
|
||||
(asio::detached);
|
||||
//end::async_execute[]
|
||||
ctx.run();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,20 +8,15 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/process.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
namespace bp = boost::process;
|
||||
using namespace boost::process;
|
||||
namespace asio = boost::asio;
|
||||
|
||||
int main()
|
||||
{
|
||||
bp::system(
|
||||
"test.exe",
|
||||
bp::start_dir="../foo"
|
||||
);
|
||||
|
||||
boost::filesystem::path exe = "test.exe";
|
||||
bp::system(
|
||||
boost::filesystem::absolute(exe),
|
||||
bp::start_dir="../foo"
|
||||
);
|
||||
// tag::start_dir[]
|
||||
asio::io_context ctx;
|
||||
process ls(ctx.get_executor(), "/ls", {}, process_start_dir("/home"));
|
||||
ls.wait();
|
||||
// end::start_dir[]
|
||||
}
|
||||
|
||||
70
example/stdio.cpp
Normal file
70
example/stdio.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
|
||||
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
|
||||
// Copyright (c) 2009 Boris Schaeling
|
||||
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
|
||||
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/process.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
using namespace boost::process;
|
||||
namespace asio = boost::asio;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
{
|
||||
//tag::readable_pipe[]
|
||||
asio::io_context ctx;
|
||||
asio::readable_pipe rp{ctx};
|
||||
|
||||
process proc(ctx, "/usr/bin/g++", {"--version"}, process_stdio{{ /* in to default */}, rp, { /* err to default */ }});
|
||||
std::string output;
|
||||
|
||||
boost::system::error_code ec;
|
||||
asio::read(rp, asio::dynamic_buffer(output), ec);
|
||||
assert(!ec || (ec == asio::error::eof));
|
||||
proc.wait();
|
||||
//end::readable_pipe[]
|
||||
}
|
||||
|
||||
{
|
||||
//tag::file[]
|
||||
asio::io_context ctx;
|
||||
// forward both stderr & stdout to stdout of the parent process
|
||||
process proc(ctx, "/usr/bin/g++", {"--version"}, process_stdio{{ /* in to default */}, stdout, stdout});
|
||||
proc.wait();
|
||||
//end::file[]
|
||||
}
|
||||
{
|
||||
//tag::null[]
|
||||
asio::io_context ctx;
|
||||
// forward stderr to /dev/null or NUL
|
||||
process proc(ctx, "/usr/bin/g++", {"--version"}, process_stdio{{ /* in to default */}, {}, nullptr});
|
||||
proc.wait();
|
||||
//end::null[]
|
||||
}
|
||||
#if defined(BOOST_POSIX_API)
|
||||
{
|
||||
//tag::native_handle[]
|
||||
asio::io_context ctx;
|
||||
// ignore stderr
|
||||
asio::local::stream_protocol::socket sock{ctx}, other{ctx};
|
||||
asio::local::connect_pair(sock, other);
|
||||
process proc(ctx, "~/not-a-virus", {}, process_stdio{sock, sock, nullptr});
|
||||
proc.wait();
|
||||
//end::native_handle[]
|
||||
}
|
||||
#endif
|
||||
{
|
||||
//tag::popen[]
|
||||
asio::io_context ctx;
|
||||
boost::process::popen proc(ctx, "/usr/bin/addr2line", {argv[0]});
|
||||
asio::write(proc, asio::buffer("main\n"));
|
||||
std::string line;
|
||||
asio::read_until(proc, asio::dynamic_buffer(line), '\n');
|
||||
//end::popen[]
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
|
||||
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
|
||||
// Copyright (c) 2009 Boris Schaeling
|
||||
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
|
||||
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/process.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace bp = boost::process;
|
||||
|
||||
int main()
|
||||
{
|
||||
bp::ipstream p;
|
||||
|
||||
bp::child c(
|
||||
"test.exe",
|
||||
bp::std_out > p
|
||||
);
|
||||
|
||||
std::string s;
|
||||
std::getline(p, s);
|
||||
|
||||
c.wait();
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
|
||||
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
|
||||
// Copyright (c) 2009 Boris Schaeling
|
||||
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
|
||||
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/process.hpp>
|
||||
|
||||
namespace bp = boost::process;
|
||||
|
||||
int main()
|
||||
{
|
||||
bp::child c("test.exe");
|
||||
c.terminate();
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
|
||||
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
|
||||
// Copyright (c) 2009 Boris Schaeling
|
||||
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
|
||||
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/process.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
namespace bp = boost::process;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
bp::child c("test.exe");
|
||||
c.wait();
|
||||
auto exit_code = c.exit_code();
|
||||
}
|
||||
|
||||
{
|
||||
boost::asio::io_context io_context;
|
||||
|
||||
bp::child c(
|
||||
"test.exe",
|
||||
io_context,
|
||||
bp::on_exit([&](int exit, const std::error_code& ec_in){})
|
||||
);
|
||||
|
||||
io_context.run();
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
|
||||
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
|
||||
// Copyright (c) 2009 Boris Schaeling
|
||||
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
|
||||
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include <boost/process.hpp>
|
||||
#include <boost/process/windows.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
namespace bp = boost::process;
|
||||
|
||||
int main()
|
||||
{
|
||||
bp::system("test.exe",
|
||||
bp::windows::show);
|
||||
|
||||
|
||||
bp::system("test.exe",
|
||||
bp::on_setup([](auto &e)
|
||||
{ e.startup_info.dwFlags = STARTF_RUNFULLSCREEN; }),
|
||||
bp::on_error([](auto&, const std::error_code & ec)
|
||||
{ std::cerr << ec.message() << std::endl; })
|
||||
);
|
||||
}
|
||||
@@ -12,30 +12,18 @@
|
||||
#ifndef BOOST_PROCESS_HPP
|
||||
#define BOOST_PROCESS_HPP
|
||||
|
||||
/**
|
||||
* \file boost/process.hpp
|
||||
*
|
||||
* Convenience header which includes all public and platform-independent
|
||||
* boost.process header files.
|
||||
*/
|
||||
|
||||
#include <boost/process/args.hpp>
|
||||
#include <boost/process/async.hpp>
|
||||
#include <boost/process/async_system.hpp>
|
||||
#include <boost/process/group.hpp>
|
||||
#include <boost/process/child.hpp>
|
||||
#include <boost/process/cmd.hpp>
|
||||
#include <boost/process/env.hpp>
|
||||
#include <boost/process/bind_launcher.hpp>
|
||||
#include <boost/process/default_launcher.hpp>
|
||||
#include <boost/process/environment.hpp>
|
||||
#include <boost/process/error.hpp>
|
||||
#include <boost/process/exe.hpp>
|
||||
#include <boost/process/group.hpp>
|
||||
#include <boost/process/io.hpp>
|
||||
#include <boost/process/pipe.hpp>
|
||||
#include <boost/process/execute.hpp>
|
||||
#include <boost/process/exit_code.hpp>
|
||||
#include <boost/process/ext.hpp>
|
||||
#include <boost/process/pid.hpp>
|
||||
#include <boost/process/popen.hpp>
|
||||
#include <boost/process/process.hpp>
|
||||
#include <boost/process/shell.hpp>
|
||||
#include <boost/process/search_path.hpp>
|
||||
#include <boost/process/spawn.hpp>
|
||||
#include <boost/process/system.hpp>
|
||||
#include <boost/process/start_dir.hpp>
|
||||
#include <boost/process/stdio.hpp>
|
||||
|
||||
#endif
|
||||
|
||||
1
include/boost/process/bind_launcher.hpp
Normal file
1
include/boost/process/bind_launcher.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/bind_launcher.hpp>
|
||||
1
include/boost/process/cstring_ref.hpp
Normal file
1
include/boost/process/cstring_ref.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/cstring_ref.hpp>
|
||||
1
include/boost/process/default_launcher.hpp
Normal file
1
include/boost/process/default_launcher.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/default_launcher.hpp>
|
||||
@@ -1,35 +0,0 @@
|
||||
// Copyright (c) 2016 Klemens D. Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_PROCESS_POSIX_ON_EXIT_HPP_
|
||||
#define BOOST_PROCESS_POSIX_ON_EXIT_HPP_
|
||||
|
||||
#include <boost/process/detail/config.hpp>
|
||||
#include <boost/process/detail/handler_base.hpp>
|
||||
#include <boost/process/detail/posix/async_handler.hpp>
|
||||
#include <system_error>
|
||||
#include <functional>
|
||||
|
||||
namespace boost { namespace process { namespace detail { namespace posix {
|
||||
|
||||
struct on_exit_ : boost::process::detail::posix::async_handler
|
||||
{
|
||||
std::function<void(int, const std::error_code&)> handler;
|
||||
on_exit_(const std::function<void(int, const std::error_code&)> & handler) : handler(handler)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
template<typename Executor>
|
||||
std::function<void(int, const std::error_code&)> on_exit_handler(Executor&)
|
||||
{
|
||||
return handler;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}}}}
|
||||
#endif /* BOOST_PROCESS_POSIX_ON_EXIT_HPP_ */
|
||||
@@ -1,210 +0,0 @@
|
||||
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
|
||||
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
|
||||
// Copyright (c) 2009 Boris Schaeling
|
||||
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
|
||||
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_PROCESS_DETAIL_POSIX_WAIT_GROUP_HPP
|
||||
#define BOOST_PROCESS_DETAIL_POSIX_WAIT_GROUP_HPP
|
||||
|
||||
#include <boost/process/detail/config.hpp>
|
||||
#include <boost/process/detail/posix/group_handle.hpp>
|
||||
#include <chrono>
|
||||
#include <system_error>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace boost { namespace process { namespace detail { namespace posix {
|
||||
|
||||
inline void wait(const group_handle &p, std::error_code &ec) noexcept
|
||||
{
|
||||
pid_t ret;
|
||||
siginfo_t status;
|
||||
|
||||
do
|
||||
{
|
||||
ret = ::waitpid(-p.grp, &status.si_status, 0);
|
||||
if (ret == -1)
|
||||
{
|
||||
ec = get_last_error();
|
||||
return;
|
||||
}
|
||||
|
||||
//ECHILD --> no child processes left.
|
||||
ret = ::waitid(P_PGID, p.grp, &status, WEXITED | WNOHANG);
|
||||
}
|
||||
while ((ret != -1) || (errno != ECHILD));
|
||||
|
||||
if (errno != ECHILD)
|
||||
ec = boost::process::detail::get_last_error();
|
||||
else
|
||||
ec.clear();
|
||||
}
|
||||
|
||||
inline void wait(const group_handle &p) noexcept
|
||||
{
|
||||
std::error_code ec;
|
||||
wait(p, ec);
|
||||
boost::process::detail::throw_error(ec, "waitpid(2) failed in wait");
|
||||
}
|
||||
|
||||
template< class Clock, class Duration >
|
||||
inline bool wait_until(
|
||||
const group_handle &p,
|
||||
const std::chrono::time_point<Clock, Duration>& time_out,
|
||||
std::error_code & ec) noexcept
|
||||
{
|
||||
|
||||
::sigset_t sigset;
|
||||
::siginfo_t siginfo;
|
||||
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset, SIGCHLD);
|
||||
|
||||
|
||||
auto get_timespec =
|
||||
[](const Duration & dur)
|
||||
{
|
||||
::timespec ts;
|
||||
ts.tv_sec = std::chrono::duration_cast<std::chrono::seconds>(dur).count();
|
||||
ts.tv_nsec = std::chrono::duration_cast<std::chrono::nanoseconds>(dur).count() % 1000000000;
|
||||
return ts;
|
||||
};
|
||||
|
||||
|
||||
bool timed_out = false;
|
||||
int ret;
|
||||
|
||||
struct ::sigaction old_sig;
|
||||
if (-1 == ::sigaction(SIGCHLD, nullptr, &old_sig))
|
||||
{
|
||||
ec = get_last_error();
|
||||
return false;
|
||||
}
|
||||
|
||||
#if defined(BOOST_POSIX_HAS_SIGTIMEDWAIT)
|
||||
do
|
||||
{
|
||||
auto ts = get_timespec(time_out - Clock::now());
|
||||
ret = ::sigtimedwait(&sigset, nullptr, &ts);
|
||||
errno = 0;
|
||||
if ((ret == SIGCHLD) && (old_sig.sa_handler != SIG_DFL) && (old_sig.sa_handler != SIG_IGN))
|
||||
old_sig.sa_handler(ret);
|
||||
|
||||
ret = ::waitpid(-p.grp, &siginfo.si_status, 0); //so in case it exited, we wanna reap it first
|
||||
if (ret == -1)
|
||||
{
|
||||
ec = get_last_error();
|
||||
return false;
|
||||
}
|
||||
|
||||
//check if we're done
|
||||
ret = ::waitid(P_PGID, p.grp, &siginfo, WEXITED | WNOHANG);
|
||||
|
||||
}
|
||||
while (((ret != -1) || (errno != ECHILD)) && !(timed_out = (Clock::now() > time_out)));
|
||||
#else
|
||||
//if we do not have sigtimedwait, we fork off a child process to get the signal in time
|
||||
pid_t timeout_pid = ::fork();
|
||||
if (timeout_pid == -1)
|
||||
{
|
||||
ec = boost::process::detail::get_last_error();
|
||||
return true;
|
||||
}
|
||||
else if (timeout_pid == 0)
|
||||
{
|
||||
auto ts = get_timespec(time_out - Clock::now());
|
||||
::setpgid(0, p.grp);
|
||||
::nanosleep(&ts, nullptr);
|
||||
::exit(0);
|
||||
}
|
||||
|
||||
struct child_cleaner_t
|
||||
{
|
||||
pid_t pid;
|
||||
~child_cleaner_t()
|
||||
{
|
||||
int res;
|
||||
::kill(pid, -15);
|
||||
::waitpid(pid, &res, WNOHANG);
|
||||
}
|
||||
};
|
||||
child_cleaner_t child_cleaner{timeout_pid};
|
||||
|
||||
do
|
||||
{
|
||||
int ret_sig = 0;
|
||||
int status;
|
||||
if ((::waitpid(timeout_pid, &status, WNOHANG) != 0)
|
||||
&& (WIFEXITED(status) || WIFSIGNALED(status)))
|
||||
ret = ::sigwait(&sigset, nullptr);
|
||||
errno = 0;
|
||||
if ((ret == SIGCHLD) && (old_sig.sa_handler != SIG_DFL) && (old_sig.sa_handler != SIG_IGN))
|
||||
old_sig.sa_handler(ret);
|
||||
|
||||
ret = ::waitpid(-p.grp, &siginfo.si_status, 0); //so in case it exited, we wanna reap it first
|
||||
if (ret == -1)
|
||||
{
|
||||
ec = get_last_error();
|
||||
return false;
|
||||
}
|
||||
|
||||
//check if we're done
|
||||
ret = ::waitid(P_PGID, p.grp, &siginfo, WEXITED | WNOHANG);
|
||||
|
||||
}
|
||||
while (((ret != -1) || (errno != ECHILD)) && !(timed_out = (Clock::now() > time_out)));
|
||||
|
||||
#endif
|
||||
|
||||
if (errno != ECHILD)
|
||||
{
|
||||
ec = boost::process::detail::get_last_error();
|
||||
return !timed_out;
|
||||
}
|
||||
else
|
||||
{
|
||||
ec.clear();
|
||||
return true; //even if timed out, there are no child proccessess left
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template< class Clock, class Duration >
|
||||
inline bool wait_until(
|
||||
const group_handle &p,
|
||||
const std::chrono::time_point<Clock, Duration>& time_out) noexcept
|
||||
{
|
||||
std::error_code ec;
|
||||
bool b = wait_until(p, time_out, ec);
|
||||
boost::process::detail::throw_error(ec, "waitpid(2) failed in wait_until");
|
||||
return b;
|
||||
}
|
||||
|
||||
template< class Rep, class Period >
|
||||
inline bool wait_for(
|
||||
const group_handle &p,
|
||||
const std::chrono::duration<Rep, Period>& rel_time,
|
||||
std::error_code & ec) noexcept
|
||||
{
|
||||
return wait_until(p, std::chrono::steady_clock::now() + rel_time, ec);
|
||||
}
|
||||
|
||||
template< class Rep, class Period >
|
||||
inline bool wait_for(
|
||||
const group_handle &p,
|
||||
const std::chrono::duration<Rep, Period>& rel_time) noexcept
|
||||
{
|
||||
std::error_code ec;
|
||||
bool b = wait_for(p, rel_time, ec);
|
||||
boost::process::detail::throw_error(ec, "waitpid(2) failed in wait_for");
|
||||
return b;
|
||||
}
|
||||
|
||||
}}}}
|
||||
|
||||
#endif
|
||||
@@ -1,17 +0,0 @@
|
||||
// Copyright (c) 2016 Klemens D. Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
#ifndef BOOST_PROCESS_TRAITS_HPP_
|
||||
#define BOOST_PROCESS_TRAITS_HPP_
|
||||
|
||||
#include <boost/process/detail/traits/decl.hpp>
|
||||
#include <boost/process/detail/traits/async.hpp>
|
||||
#include <boost/process/detail/traits/cmd_or_exe.hpp>
|
||||
#include <boost/process/detail/traits/env.hpp>
|
||||
#include <boost/process/detail/traits/error.hpp>
|
||||
#include <boost/process/detail/traits/wchar_t.hpp>
|
||||
|
||||
#endif /* BOOST_PROCESS_TRAITS_HPP_ */
|
||||
@@ -1,705 +1 @@
|
||||
// Copyright (c) 2016 Klemens D. Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
|
||||
#ifndef BOOST_PROCESS_ENVIRONMENT_HPP_
|
||||
#define BOOST_PROCESS_ENVIRONMENT_HPP_
|
||||
|
||||
#include <boost/process/detail/config.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#if defined(BOOST_POSIX_API)
|
||||
#include <boost/process/detail/posix/environment.hpp>
|
||||
#elif defined(BOOST_WINDOWS_API)
|
||||
#include <boost/process/detail/windows/environment.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost { namespace process {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template<typename Char, typename Environment>
|
||||
struct const_entry
|
||||
{
|
||||
using value_type = Char ;
|
||||
using pointer = const value_type * ;
|
||||
using string_type = std::basic_string<value_type> ;
|
||||
using range = boost::iterator_range<pointer> ;
|
||||
using environment_t = Environment ;
|
||||
|
||||
std::vector<string_type> to_vector() const
|
||||
{
|
||||
if (_data == nullptr)
|
||||
return std::vector<string_type>();
|
||||
std::vector<string_type> data;
|
||||
auto str = string_type(_data);
|
||||
struct splitter
|
||||
{
|
||||
bool operator()(wchar_t w) const {return w == api::env_seperator<wchar_t>();}
|
||||
bool operator()(char c) const {return c == api::env_seperator<char> ();}
|
||||
} s;
|
||||
boost::split(data, _data, s);
|
||||
return std::move(data);
|
||||
}
|
||||
string_type to_string() const
|
||||
{
|
||||
if (_data != nullptr)
|
||||
return string_type(_data);
|
||||
else
|
||||
return string_type();
|
||||
}
|
||||
string_type get_name() const {return string_type(_name.begin(), _name.end());}
|
||||
explicit const_entry(string_type&& name, pointer data, environment_t & env_) :
|
||||
_name(std::move(name)), _data(data), _env(&env_) {}
|
||||
|
||||
explicit const_entry(string_type &&name, environment_t & env) :
|
||||
_name(std::move(name)), _data(nullptr), _env(&env) {}
|
||||
const_entry(const const_entry&) = default;
|
||||
const_entry& operator=(const const_entry&) = default;
|
||||
|
||||
void reload()
|
||||
{
|
||||
auto p = _env->find(_name);
|
||||
if (p == _env->end())
|
||||
_data = nullptr;
|
||||
else
|
||||
_data = p->_data;
|
||||
this->_env->reload();
|
||||
|
||||
}
|
||||
bool empty() const
|
||||
{
|
||||
return _data == nullptr;
|
||||
}
|
||||
protected:
|
||||
string_type _name;
|
||||
pointer _data;
|
||||
environment_t * _env;
|
||||
};
|
||||
|
||||
template<typename Char, typename Environment>
|
||||
struct entry : const_entry<Char, Environment>
|
||||
{
|
||||
using father = const_entry<Char, Environment>;
|
||||
using value_type = typename father::value_type;
|
||||
using string_type = typename father::string_type;
|
||||
using pointer = typename father::pointer;
|
||||
using environment_t = typename father::environment_t;
|
||||
|
||||
explicit entry(string_type&& name, pointer data, environment_t & env) :
|
||||
father(std::move(name), data, env) {}
|
||||
|
||||
explicit entry(string_type &&name, environment_t & env_) :
|
||||
father(std::move(name), env_) {}
|
||||
|
||||
entry(const entry&) = default;
|
||||
entry& operator=(const entry&) = default;
|
||||
|
||||
void assign(const string_type &value)
|
||||
{
|
||||
this->_env->set(this->_name, value);
|
||||
this->reload();
|
||||
}
|
||||
void assign(const std::vector<string_type> &value)
|
||||
{
|
||||
string_type data;
|
||||
for (auto &v : value)
|
||||
{
|
||||
if (&v != &value.front())
|
||||
data += api::env_seperator<value_type>();
|
||||
data += v;
|
||||
}
|
||||
this->_env->set(this->_name, data);
|
||||
this->reload();
|
||||
|
||||
}
|
||||
void assign(const std::initializer_list<string_type> &value)
|
||||
{
|
||||
string_type data;
|
||||
for (auto &v : value)
|
||||
{
|
||||
if (&v != &*value.begin())
|
||||
data += api::env_seperator<value_type>();
|
||||
data += v;
|
||||
}
|
||||
this->_env->set(this->_name, data);
|
||||
this->reload();
|
||||
|
||||
}
|
||||
void append(const string_type &value)
|
||||
{
|
||||
if (this->_data == nullptr)
|
||||
this->_env->set(this->_name, value);
|
||||
else
|
||||
{
|
||||
string_type st = this->_data;
|
||||
this->_env->set(this->_name, st + api::env_seperator<value_type>() + value);
|
||||
}
|
||||
|
||||
|
||||
this->reload();
|
||||
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
this->_env->reset(this->_name);
|
||||
this->_env->reload();
|
||||
this->_data = nullptr;
|
||||
}
|
||||
entry &operator=(const string_type & value)
|
||||
{
|
||||
assign(value);
|
||||
return *this;
|
||||
}
|
||||
entry &operator=(const std::vector<string_type> & value)
|
||||
{
|
||||
assign(value);
|
||||
return *this;
|
||||
}
|
||||
entry &operator=(const std::initializer_list<string_type> & value)
|
||||
{
|
||||
assign(value);
|
||||
return *this;
|
||||
}
|
||||
entry &operator+=(const string_type & value)
|
||||
{
|
||||
append(value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
template<typename Char, typename Environment>
|
||||
struct make_entry
|
||||
{
|
||||
|
||||
make_entry(const make_entry&) = default;
|
||||
make_entry& operator=(const make_entry&) = default;
|
||||
|
||||
Environment *env;
|
||||
make_entry(Environment & env) : env(&env) {};
|
||||
entry<Char, Environment> operator()(const Char* data) const
|
||||
{
|
||||
auto p = data;
|
||||
while ((*p != equal_sign<Char>()) && (*p != null_char<Char>()))
|
||||
p++;
|
||||
auto name = std::basic_string<Char>(data, p);
|
||||
p++; //go behind equal sign
|
||||
|
||||
return entry<Char, Environment>(std::move(name), p, *env);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Char, typename Environment>
|
||||
struct make_const_entry
|
||||
{
|
||||
|
||||
make_const_entry(const make_const_entry&) = default;
|
||||
make_const_entry& operator=(const make_const_entry&) = default;
|
||||
|
||||
Environment *env;
|
||||
make_const_entry(Environment & env) : env(&env) {};
|
||||
const_entry<Char, Environment> operator()(const Char* data) const
|
||||
{
|
||||
auto p = data;
|
||||
while ((*p != equal_sign<Char>()) && (*p != null_char<Char>()))
|
||||
p++;
|
||||
auto name = std::basic_string<Char>(data, p);
|
||||
p++; //go behind equal sign
|
||||
|
||||
return const_entry<Char, Environment>(std::move(name), p, *env);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#if !defined (BOOST_PROCESS_DOXYGEN)
|
||||
|
||||
template<typename Char, template <class> class Implementation = detail::api::basic_environment_impl>
|
||||
class basic_environment_impl : public Implementation<Char>
|
||||
{
|
||||
Char** _get_end() const
|
||||
{
|
||||
auto p = this->_env_impl;
|
||||
while (*p != nullptr)
|
||||
p++;
|
||||
|
||||
return p;
|
||||
}
|
||||
public:
|
||||
using string_type = std::basic_string<Char>;
|
||||
using implementation_type = Implementation<Char>;
|
||||
using base_type = basic_environment_impl<Char, Implementation>;
|
||||
using entry_maker = detail::make_entry<Char, base_type>;
|
||||
using entry_type = detail::entry <Char, base_type>;
|
||||
using const_entry_type = detail::const_entry <Char, const base_type>;
|
||||
using const_entry_maker = detail::make_const_entry<Char, const base_type>;
|
||||
|
||||
friend entry_type;
|
||||
friend const_entry_type;
|
||||
|
||||
using iterator = boost::transform_iterator< entry_maker, Char**, entry_type, entry_type>;
|
||||
using const_iterator = boost::transform_iterator<const_entry_maker, Char**, const_entry_type, const_entry_type>;
|
||||
using size_type = std::size_t;
|
||||
|
||||
iterator begin() {return iterator(this->_env_impl, entry_maker(*this));}
|
||||
const_iterator begin() const {return const_iterator(this->_env_impl, const_entry_maker(*this));}
|
||||
const_iterator cbegin() const {return const_iterator(this->_env_impl, const_entry_maker(*this));}
|
||||
|
||||
iterator end() {return iterator(_get_end(), entry_maker(*this));}
|
||||
const_iterator end() const {return const_iterator(_get_end(), const_entry_maker(*this));}
|
||||
const_iterator cend() const {return const_iterator(_get_end(), const_entry_maker(*this));}
|
||||
|
||||
iterator find( const string_type& key )
|
||||
{
|
||||
auto p = this->_env_impl;
|
||||
auto st1 = key + ::boost::process::detail::equal_sign<Char>();
|
||||
while (*p != nullptr)
|
||||
{
|
||||
if (std::equal(st1.begin(), st1.end(), *p))
|
||||
break;
|
||||
p++;
|
||||
}
|
||||
return iterator(p, entry_maker(*this));
|
||||
}
|
||||
const_iterator find( const string_type& key ) const
|
||||
{
|
||||
auto p = this->_env_impl;
|
||||
auto st1 = key + ::boost::process::detail::equal_sign<Char>();
|
||||
while (*p != nullptr)
|
||||
{
|
||||
if (std::equal(st1.begin(), st1.end(), *p))
|
||||
break;
|
||||
p++;
|
||||
}
|
||||
return const_iterator(p, const_entry_maker(*this));
|
||||
}
|
||||
|
||||
std::size_t count(const string_type & st) const
|
||||
{
|
||||
auto p = this->_env_impl;
|
||||
auto st1 = st + ::boost::process::detail::equal_sign<Char>();
|
||||
while (*p != nullptr)
|
||||
{
|
||||
if (std::equal(st1.begin(), st1.end(), *p))
|
||||
return 1u;
|
||||
p++;
|
||||
}
|
||||
return 0u;
|
||||
}
|
||||
void erase(const string_type & id)
|
||||
{
|
||||
implementation_type::reset(id);
|
||||
this->reload();
|
||||
}
|
||||
std::pair<iterator,bool> emplace(const string_type & id, const string_type & value)
|
||||
{
|
||||
auto f = find(id);
|
||||
if (f == end())
|
||||
{
|
||||
implementation_type::set(id, value);
|
||||
this->reload();
|
||||
return std::pair<iterator, bool>(find(id), true);
|
||||
}
|
||||
else
|
||||
return std::pair<iterator, bool>(f, false);
|
||||
}
|
||||
using implementation_type::implementation_type;
|
||||
using implementation_type::operator=;
|
||||
using native_handle_type = typename implementation_type::native_handle_type;
|
||||
using implementation_type::native_handle;
|
||||
//copy ctor if impl is copy-constructible
|
||||
bool empty()
|
||||
{
|
||||
return *this->_env_impl == nullptr;
|
||||
}
|
||||
std::size_t size() const
|
||||
{
|
||||
return (_get_end() - this->_env_impl);
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
std::vector<string_type> names;
|
||||
names.resize(size());
|
||||
std::transform(cbegin(), cend(), names.begin(), [](const const_entry_type & cet){return cet.get_name();});
|
||||
|
||||
for (auto & nm : names)
|
||||
implementation_type::reset(nm);
|
||||
|
||||
this->reload();
|
||||
}
|
||||
|
||||
entry_type at( const string_type& key )
|
||||
{
|
||||
auto f = find(key);
|
||||
if (f== end())
|
||||
throw std::out_of_range(key + " not found");
|
||||
return *f;
|
||||
}
|
||||
const_entry_type at( const string_type& key ) const
|
||||
{
|
||||
auto f = find(key);
|
||||
if (f== end())
|
||||
throw std::out_of_range(key + " not found");
|
||||
return *f;
|
||||
}
|
||||
entry_type operator[](const string_type & key)
|
||||
{
|
||||
auto p = find(key);
|
||||
if (p != end())
|
||||
return *p;
|
||||
|
||||
return entry_type(string_type(key), *this);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_PROCESS_DOXYGEN)
|
||||
/**Template representation of environments. It takes a character type (`char` or `wchar_t`)
|
||||
* as template parameter to implement the environment
|
||||
*/
|
||||
template<typename Char>
|
||||
class basic_environment
|
||||
{
|
||||
|
||||
public:
|
||||
typedef std::basic_string<Char> string_type;
|
||||
typedef boost::transform_iterator< entry_maker, Char**> iterator ;
|
||||
typedef boost::transform_iterator<const_entry_maker, Char**> const_iterator ;
|
||||
typedef std::size_t size_type ;
|
||||
|
||||
iterator begin() ; ///<Returns an iterator to the beginning
|
||||
const_iterator begin() const ; ///<Returns an iterator to the beginning
|
||||
const_iterator cbegin() const ; ///<Returns an iterator to the beginning
|
||||
|
||||
iterator end() ; ///<Returns an iterator to the end
|
||||
const_iterator end() const; ///<Returns an iterator to the end
|
||||
const_iterator cend() const; ///<Returns an iterator to the end
|
||||
|
||||
iterator find( const string_type& key ); ///<Find a variable by its name
|
||||
const_iterator find( const string_type& key ) const; ///<Find a variable by its name
|
||||
|
||||
std::size_t count(const string_type & st) const; ///<Number of variables
|
||||
void erase(const string_type & id); ///<Erase variable by id.
|
||||
///Emplace an environment variable.
|
||||
std::pair<iterator,bool> emplace(const string_type & id, const string_type & value);
|
||||
|
||||
///Default constructor
|
||||
basic_environment();
|
||||
///Copy constructor.
|
||||
basic_environment(const basic_environment & );
|
||||
///Move constructor.
|
||||
basic_environment(basic_environment && );
|
||||
|
||||
///Copy assignment.
|
||||
basic_environment& operator=(const basic_environment & );
|
||||
///Move assignment.
|
||||
basic_environment& operator=(basic_environment && );
|
||||
|
||||
typedef typename detail::implementation_type::native_handle_type native_handle;
|
||||
|
||||
///Check if environment has entries.
|
||||
bool empty();
|
||||
///Get the number of variables.
|
||||
std::size_t size() const;
|
||||
///Clear the environment. @attention Use with care, passed environment cannot be empty.
|
||||
void clear();
|
||||
///Get the entry with the key. Throws if it does not exist.
|
||||
entry_type at( const string_type& key );
|
||||
///Get the entry with the key. Throws if it does not exist.
|
||||
const_entry_type at( const string_type& key ) const;
|
||||
///Get the entry with the given key. It creates the entry if it doesn't exist.
|
||||
entry_type operator[](const string_type & key);
|
||||
|
||||
/**Proxy class used for read access to members by [] or .at()
|
||||
* @attention Holds a reference to the environment it was created from.
|
||||
*/
|
||||
template<typename Char, typename Environment>
|
||||
struct const_entry_type
|
||||
{
|
||||
typedef Char value_type;
|
||||
typedef const value_type * pointer;
|
||||
typedef std::basic_string<value_type> string_type;
|
||||
typedef boost::iterator_range<pointer> range;
|
||||
typedef Environment environment_t;
|
||||
|
||||
///Split the entry by ";" or ":" and return it as a vector. Used by PATH.
|
||||
std::vector<string_type> to_vector() const
|
||||
///Get the value as string.
|
||||
string_type to_string() const
|
||||
///Get the name of this entry.
|
||||
string_type get_name() const {return string_type(_name.begin(), _name.end());}
|
||||
///Copy Constructor
|
||||
const_entry(const const_entry&) = default;
|
||||
///Move Constructor
|
||||
const_entry& operator=(const const_entry&) = default;
|
||||
///Check if the entry is empty.
|
||||
bool empty() const;
|
||||
};
|
||||
|
||||
/**Proxy class used for read and write access to members by [] or .at()
|
||||
* @attention Holds a reference to the environment it was created from.
|
||||
*/
|
||||
template<typename Char, typename Environment>
|
||||
struct entry_type
|
||||
{
|
||||
|
||||
typedef Char value_type;
|
||||
typedef const value_type * pointer;
|
||||
typedef std::basic_string<value_type> string_type;
|
||||
typedef boost::iterator_range<pointer> range;
|
||||
typedef Environment environment_t;
|
||||
|
||||
///Split the entry by ";" or ":" and return it as a vector. Used by PATH.
|
||||
std::vector<string_type> to_vector() const
|
||||
///Get the value as string.
|
||||
string_type to_string() const
|
||||
///Get the name of this entry.
|
||||
string_type get_name() const {return string_type(_name.begin(), _name.end());}
|
||||
///Copy Constructor
|
||||
entry(const entry&) = default;
|
||||
///Move Constructor
|
||||
entry& operator=(const entry&) = default;
|
||||
///Check if the entry is empty.
|
||||
bool empty() const;
|
||||
|
||||
///Assign a string to the value
|
||||
void assign(const string_type &value);
|
||||
///Assign a set of strings to the entry; they will be separated by ';' or ':'.
|
||||
void assign(const std::vector<string_type> &value);
|
||||
///Append a string to the end of the entry, it will separated by ';' or ':'.
|
||||
void append(const string_type &value);
|
||||
///Reset the value
|
||||
void clear();
|
||||
///Assign a string to the entry.
|
||||
entry &operator=(const string_type & value);
|
||||
///Assign a set of strings to the entry; they will be separated by ';' or ':'.
|
||||
entry &operator=(const std::vector<string_type> & value);
|
||||
///Append a string to the end of the entry, it will separated by ';' or ':'.
|
||||
entry &operator+=(const string_type & value);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
/**Template representation of the environment of this process. It takes a template
|
||||
* as template parameter to implement the environment. All instances of this class
|
||||
* refer to the same environment, but might not get updated if another one makes changes.
|
||||
*/
|
||||
template<typename Char>
|
||||
class basic_native_environment
|
||||
{
|
||||
|
||||
public:
|
||||
typedef std::basic_string<Char> string_type;
|
||||
typedef boost::transform_iterator< entry_maker, Char**> iterator ;
|
||||
typedef boost::transform_iterator<const_entry_maker, Char**> const_iterator ;
|
||||
typedef std::size_t size_type ;
|
||||
|
||||
iterator begin() ; ///<Returns an iterator to the beginning
|
||||
const_iterator begin() const ; ///<Returns an iterator to the beginning
|
||||
const_iterator cbegin() const ; ///<Returns an iterator to the beginning
|
||||
|
||||
iterator end() ; ///<Returns an iterator to the end
|
||||
const_iterator end() const; ///<Returns an iterator to the end
|
||||
const_iterator cend() const; ///<Returns an iterator to the end
|
||||
|
||||
iterator find( const string_type& key ); ///<Find a variable by its name
|
||||
const_iterator find( const string_type& key ) const; ///<Find a variable by its name
|
||||
|
||||
std::size_t count(const string_type & st) const; ///<Number of variables
|
||||
void erase(const string_type & id); ///<Erase variable by id.
|
||||
///Emplace an environment variable.
|
||||
std::pair<iterator,bool> emplace(const string_type & id, const string_type & value);
|
||||
|
||||
///Default constructor
|
||||
basic_native_environment();
|
||||
///Move constructor.
|
||||
basic_native_environment(basic_native_environment && );
|
||||
///Move assignment.
|
||||
basic_native_environment& operator=(basic_native_environment && );
|
||||
|
||||
typedef typename detail::implementation_type::native_handle_type native_handle;
|
||||
|
||||
///Check if environment has entries.
|
||||
bool empty();
|
||||
///Get the number of variables.
|
||||
std::size_t size() const;
|
||||
///Get the entry with the key. Throws if it does not exist.
|
||||
entry_type at( const string_type& key );
|
||||
///Get the entry with the key. Throws if it does not exist.
|
||||
const_entry_type at( const string_type& key ) const;
|
||||
///Get the entry with the given key. It creates the entry if it doesn't exist.
|
||||
entry_type operator[](const string_type & key);
|
||||
|
||||
/**Proxy class used for read access to members by [] or .at()
|
||||
* @attention Holds a reference to the environment it was created from.
|
||||
*/
|
||||
template<typename Char, typename Environment>
|
||||
struct const_entry_type
|
||||
{
|
||||
typedef Char value_type;
|
||||
typedef const value_type * pointer;
|
||||
typedef std::basic_string<value_type> string_type;
|
||||
typedef boost::iterator_range<pointer> range;
|
||||
typedef Environment environment_t;
|
||||
|
||||
///Split the entry by ";" or ":" and return it as a vector. Used by PATH.
|
||||
std::vector<string_type> to_vector() const
|
||||
///Get the value as string.
|
||||
string_type to_string() const
|
||||
///Get the name of this entry.
|
||||
string_type get_name() const {return string_type(_name.begin(), _name.end());}
|
||||
///Copy Constructor
|
||||
const_entry(const const_entry&) = default;
|
||||
///Move Constructor
|
||||
const_entry& operator=(const const_entry&) = default;
|
||||
///Check if the entry is empty.
|
||||
bool empty() const;
|
||||
};
|
||||
|
||||
/**Proxy class used for read and write access to members by [] or .at()
|
||||
* @attention Holds a reference to the environment it was created from.
|
||||
*/
|
||||
template<typename Char, typename Environment>
|
||||
struct entry_type
|
||||
{
|
||||
|
||||
typedef Char value_type;
|
||||
typedef const value_type * pointer;
|
||||
typedef std::basic_string<value_type> string_type;
|
||||
typedef boost::iterator_range<pointer> range;
|
||||
typedef Environment environment_t;
|
||||
|
||||
///Split the entry by ";" or ":" and return it as a vector. Used by PATH.
|
||||
std::vector<string_type> to_vector() const
|
||||
///Get the value as string.
|
||||
string_type to_string() const
|
||||
///Get the name of this entry.
|
||||
string_type get_name() const {return string_type(_name.begin(), _name.end());}
|
||||
///Copy Constructor
|
||||
entry(const entry&) = default;
|
||||
///Move Constructor
|
||||
entry& operator=(const entry&) = default;
|
||||
///Check if the entry is empty.
|
||||
bool empty() const;
|
||||
|
||||
///Assign a string to the value
|
||||
void assign(const string_type &value);
|
||||
///Assign a set of strings to the entry; they will be separated by ';' or ':'.
|
||||
void assign(const std::vector<string_type> &value);
|
||||
///Append a string to the end of the entry, it will separated by ';' or ':'.
|
||||
void append(const string_type &value);
|
||||
///Reset the value
|
||||
void clear();
|
||||
///Assign a string to the entry.
|
||||
entry &operator=(const string_type & value);
|
||||
///Assign a set of strings to the entry; they will be separated by ';' or ':'.
|
||||
entry &operator=(const std::vector<string_type> & value);
|
||||
///Append a string to the end of the entry, it will separated by ';' or ':'.
|
||||
entry &operator+=(const string_type & value);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
///Definition of the environment for the current process.
|
||||
template<typename Char>
|
||||
class basic_native_environment : public basic_environment_impl<Char, detail::api::native_environment_impl>
|
||||
{
|
||||
public:
|
||||
using base_type = basic_environment_impl<Char, detail::api::native_environment_impl>;
|
||||
using base_type::base_type;
|
||||
using base_type::operator=;
|
||||
};
|
||||
|
||||
///Type definition to hold a seperate environment.
|
||||
template<typename Char>
|
||||
class basic_environment : public basic_environment_impl<Char, detail::api::basic_environment_impl>
|
||||
{
|
||||
public:
|
||||
using base_type = basic_environment_impl<Char, detail::api::basic_environment_impl>;
|
||||
using base_type::base_type;
|
||||
using base_type::operator=;
|
||||
};
|
||||
|
||||
|
||||
#if !defined(BOOST_NO_ANSI_APIS)
|
||||
///Definition of the environment for the current process.
|
||||
typedef basic_native_environment<char> native_environment;
|
||||
#endif
|
||||
///Definition of the environment for the current process.
|
||||
typedef basic_native_environment<wchar_t> wnative_environment;
|
||||
|
||||
#if !defined(BOOST_NO_ANSI_APIS)
|
||||
///Type definition to hold a seperate environment.
|
||||
typedef basic_environment<char> environment;
|
||||
#endif
|
||||
///Type definition to hold a seperate environment.
|
||||
typedef basic_environment<wchar_t> wenvironment;
|
||||
|
||||
}
|
||||
|
||||
///Namespace containing information of the calling process.
|
||||
namespace this_process
|
||||
{
|
||||
|
||||
///Definition of the native handle type.
|
||||
typedef ::boost::process::detail::api::native_handle_t native_handle_type;
|
||||
|
||||
#if !defined(BOOST_NO_ANSI_APIS)
|
||||
///Definition of the environment for this process.
|
||||
using ::boost::process::native_environment;
|
||||
#endif
|
||||
///Definition of the environment for this process.
|
||||
using ::boost::process::wnative_environment;
|
||||
|
||||
///Get the process id of the current process.
|
||||
inline int get_id() { return ::boost::process::detail::api::get_id();}
|
||||
///Get the native handle of the current process.
|
||||
inline native_handle_type native_handle() { return ::boost::process::detail::api::native_handle();}
|
||||
#if !defined(BOOST_NO_ANSI_APIS)
|
||||
///Get the enviroment of the current process.
|
||||
inline native_environment environment() { return ::boost::process:: native_environment(); }
|
||||
#endif
|
||||
///Get the enviroment of the current process.
|
||||
inline wnative_environment wenvironment() { return ::boost::process::wnative_environment(); }
|
||||
///Get the path environment variable of the current process runs.
|
||||
inline std::vector<boost::filesystem::path> path()
|
||||
{
|
||||
#if defined(BOOST_WINDOWS_API)
|
||||
const ::boost::process::wnative_environment ne{};
|
||||
typedef typename ::boost::process::wnative_environment::const_entry_type value_type;
|
||||
const auto id = L"PATH";
|
||||
#else
|
||||
const ::boost::process::native_environment ne{};
|
||||
typedef typename ::boost::process::native_environment::const_entry_type value_type;
|
||||
const auto id = "PATH";
|
||||
#endif
|
||||
|
||||
auto itr = std::find_if(ne.cbegin(), ne.cend(),
|
||||
[&](const value_type & e)
|
||||
{return id == ::boost::to_upper_copy(e.get_name(), ::boost::process::detail::process_locale());});
|
||||
|
||||
if (itr == ne.cend())
|
||||
return {};
|
||||
|
||||
auto vec = itr->to_vector();
|
||||
|
||||
std::vector<boost::filesystem::path> val;
|
||||
val.resize(vec.size());
|
||||
|
||||
std::copy(vec.begin(), vec.end(), val.begin());
|
||||
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* INCLUDE_BOOST_PROCESS_DETAIL_ENVIRONMENT_HPP_ */
|
||||
#include <boost/process/v2/environment.hpp>
|
||||
|
||||
@@ -1,211 +1 @@
|
||||
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
|
||||
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
|
||||
// Copyright (c) 2009 Boris Schaeling
|
||||
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
|
||||
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
|
||||
// Copyright (c) 2016 Klemens D. Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_PROCESS_DETAIL_ERROR_HPP
|
||||
#define BOOST_PROCESS_DETAIL_ERROR_HPP
|
||||
|
||||
#include <boost/process/detail/config.hpp>
|
||||
#include <boost/process/detail/traits.hpp>
|
||||
|
||||
|
||||
#if defined(BOOST_POSIX_API)
|
||||
#include <boost/process/detail/posix/handler.hpp>
|
||||
#elif defined(BOOST_WINDOWS_API)
|
||||
#include <boost/process/detail/windows/handler.hpp>
|
||||
#endif
|
||||
|
||||
#include <system_error>
|
||||
|
||||
#include <type_traits>
|
||||
#include <boost/fusion/algorithm/query/find_if.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
#include <boost/fusion/container/vector/convert.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
#include <boost/fusion/sequence/comparison/equal_to.hpp>
|
||||
#include <boost/fusion/container/set/convert.hpp>
|
||||
#include <boost/type_index.hpp>
|
||||
|
||||
/** \file boost/process/error.hpp
|
||||
*
|
||||
* Header which provides the error properties. It allows to explicitly set the error handling, the properties are:
|
||||
*
|
||||
\xmlonly
|
||||
<programlisting>
|
||||
namespace boost {
|
||||
namespace process {
|
||||
<emphasis>unspecified</emphasis> <globalname alt="boost::process::ignore_error">ignore_error</globalname>;
|
||||
<emphasis>unspecified</emphasis> <globalname alt="boost::process::throw_on_error">throw_on_error</globalname>;
|
||||
<emphasis>unspecified</emphasis> <globalname alt="boost::process::error">error</globalname>;
|
||||
<emphasis>unspecified</emphasis> <globalname alt="boost::process::error_ref">error_ref</globalname>;
|
||||
<emphasis>unspecified</emphasis> <globalname alt="boost::process::error_code">error_code</globalname>;
|
||||
}
|
||||
}
|
||||
</programlisting>
|
||||
\endxmlonly
|
||||
* For error there are two aliases: error_ref and error_code
|
||||
*/
|
||||
|
||||
namespace boost { namespace process {
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct throw_on_error_ : ::boost::process::detail::api::handler_base_ext
|
||||
{
|
||||
constexpr throw_on_error_() {};
|
||||
|
||||
template <class Executor>
|
||||
void on_error(Executor&, const std::error_code & ec) const
|
||||
{
|
||||
throw process_error(ec, "process creation failed");
|
||||
}
|
||||
|
||||
const throw_on_error_ &operator()() const {return *this;}
|
||||
};
|
||||
|
||||
struct ignore_error_ : ::boost::process::detail::api::handler_base_ext
|
||||
{
|
||||
constexpr ignore_error_() {};
|
||||
};
|
||||
|
||||
struct set_on_error : ::boost::process::detail::api::handler_base_ext
|
||||
{
|
||||
set_on_error(const set_on_error&) = default;
|
||||
explicit set_on_error(std::error_code &ec) : ec_(ec) {}
|
||||
|
||||
template <class Executor>
|
||||
void on_error(Executor&, const std::error_code & ec) const
|
||||
{
|
||||
ec_ = ec;
|
||||
}
|
||||
|
||||
private:
|
||||
std::error_code &ec_;
|
||||
};
|
||||
|
||||
struct error_
|
||||
{
|
||||
constexpr error_() {}
|
||||
set_on_error operator()(std::error_code &ec) const {return set_on_error(ec);}
|
||||
set_on_error operator= (std::error_code &ec) const {return set_on_error(ec);}
|
||||
|
||||
};
|
||||
|
||||
|
||||
template<typename T>
|
||||
struct is_error_handler : std::false_type {};
|
||||
|
||||
template<> struct is_error_handler<set_on_error> : std::true_type {};
|
||||
template<> struct is_error_handler<throw_on_error_> : std::true_type {};
|
||||
template<> struct is_error_handler<ignore_error_> : std::true_type {};
|
||||
|
||||
|
||||
|
||||
template<typename Iterator, typename End>
|
||||
struct has_error_handler_impl
|
||||
{
|
||||
typedef typename boost::fusion::result_of::deref<Iterator>::type ref_type;
|
||||
typedef typename std::remove_reference<ref_type>::type res_type_;
|
||||
typedef typename std::remove_cv<res_type_>::type res_type;
|
||||
typedef typename is_error_handler<res_type>::type cond;
|
||||
|
||||
typedef typename boost::fusion::result_of::next<Iterator>::type next_itr;
|
||||
typedef typename has_error_handler_impl<next_itr, End>::type next;
|
||||
|
||||
typedef typename boost::mpl::or_<cond, next>::type type;
|
||||
};
|
||||
|
||||
template<typename Iterator>
|
||||
struct has_error_handler_impl<Iterator, Iterator>
|
||||
{
|
||||
typedef boost::mpl::false_ type;
|
||||
};
|
||||
|
||||
|
||||
template<typename Sequence>
|
||||
struct has_error_handler
|
||||
{
|
||||
typedef typename boost::fusion::result_of::as_vector<Sequence>::type vector_type;
|
||||
|
||||
typedef typename has_error_handler_impl<
|
||||
typename boost::fusion::result_of::begin<vector_type>::type,
|
||||
typename boost::fusion::result_of::end< vector_type>::type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template<typename Sequence>
|
||||
struct has_ignore_error
|
||||
{
|
||||
typedef typename boost::fusion::result_of::as_set<Sequence>::type set_type;
|
||||
typedef typename boost::fusion::result_of::has_key<set_type, ignore_error_>::type type1;
|
||||
typedef typename boost::fusion::result_of::has_key<set_type, ignore_error_&>::type type2;
|
||||
typedef typename boost::fusion::result_of::has_key<set_type, const ignore_error_&>::type type3;
|
||||
typedef typename boost::mpl::or_<type1,type2, type3>::type type;
|
||||
};
|
||||
|
||||
struct error_builder
|
||||
{
|
||||
std::error_code *err;
|
||||
typedef set_on_error result_type;
|
||||
set_on_error get_initializer() {return set_on_error(*err);};
|
||||
void operator()(std::error_code & ec) {err = &ec;};
|
||||
};
|
||||
|
||||
template<>
|
||||
struct initializer_tag<std::error_code>
|
||||
{
|
||||
typedef error_tag type;
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct initializer_builder<error_tag>
|
||||
{
|
||||
typedef error_builder type;
|
||||
};
|
||||
|
||||
}
|
||||
/**The ignore_error property will disable any error handling. This can be useful
|
||||
on linux, where error handling will require a pipe.*/
|
||||
constexpr boost::process::detail::ignore_error_ ignore_error;
|
||||
/**The throw_on_error property will enable the exception when launching a process.
|
||||
It is unnecessary by default, but may be used, when an additional error_code is provided.*/
|
||||
constexpr boost::process::detail::throw_on_error_ throw_on_error;
|
||||
/**
|
||||
The error property will set the executor to handle any errors by setting an
|
||||
[std::error_code](http://en.cppreference.com/w/cpp/error/error_code).
|
||||
|
||||
\code{.cpp}
|
||||
std::error_code ec;
|
||||
system("gcc", error(ec));
|
||||
\endcode
|
||||
|
||||
The following syntax is valid:
|
||||
|
||||
\code{.cpp}
|
||||
error(ec);
|
||||
error=ec;
|
||||
\endcode
|
||||
|
||||
The overload version is achieved by just passing an object of
|
||||
[std::error_code](http://en.cppreference.com/w/cpp/error/error_code) to the function.
|
||||
|
||||
|
||||
*/
|
||||
constexpr boost::process::detail::error_ error;
|
||||
///Alias for \xmlonly <globalname alt="boost::process::error">error</globalname> \endxmlonly .
|
||||
constexpr boost::process::detail::error_ error_ref;
|
||||
///Alias for \xmlonly <globalname alt="boost::process::error">error</globalname> \endxmlonly .
|
||||
constexpr boost::process::detail::error_ error_code;
|
||||
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
#include <boost/process/v2/error.hpp>
|
||||
|
||||
1
include/boost/process/execute.hpp
Normal file
1
include/boost/process/execute.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/execute.hpp>
|
||||
1
include/boost/process/exit_code.hpp
Normal file
1
include/boost/process/exit_code.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/exit_code.hpp>
|
||||
1
include/boost/process/ext.hpp
Normal file
1
include/boost/process/ext.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/ext.hpp>
|
||||
1
include/boost/process/ext/cmd.hpp
Normal file
1
include/boost/process/ext/cmd.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/ext/cmd.hpp>
|
||||
1
include/boost/process/ext/cwd.hpp
Normal file
1
include/boost/process/ext/cwd.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/ext/cwd.hpp>
|
||||
1
include/boost/process/ext/env.hpp
Normal file
1
include/boost/process/ext/env.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/ext/env.hpp>
|
||||
1
include/boost/process/ext/exe.hpp
Normal file
1
include/boost/process/ext/exe.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/ext/exe.hpp>
|
||||
1
include/boost/process/pid.hpp
Normal file
1
include/boost/process/pid.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/pid.hpp>
|
||||
1
include/boost/process/popen.hpp
Normal file
1
include/boost/process/popen.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/popen.hpp>
|
||||
1
include/boost/process/posix/bind_fd.hpp
Normal file
1
include/boost/process/posix/bind_fd.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/posix/bind_fd.hpp>
|
||||
1
include/boost/process/posix/default_launcher.hpp
Normal file
1
include/boost/process/posix/default_launcher.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/posix/default_launcher.hpp>
|
||||
1
include/boost/process/posix/fork_and_forget_launcher.hpp
Normal file
1
include/boost/process/posix/fork_and_forget_launcher.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/posix/fork_and_forget_launcher.hpp>
|
||||
1
include/boost/process/posix/pdfork_launcher.hpp
Normal file
1
include/boost/process/posix/pdfork_launcher.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/posix/pdfork_launcher.hpp>
|
||||
1
include/boost/process/posix/vfork_launcher.hpp
Normal file
1
include/boost/process/posix/vfork_launcher.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/posix/vfork_launcher.hpp>
|
||||
1
include/boost/process/process.hpp
Normal file
1
include/boost/process/process.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/process.hpp>
|
||||
1
include/boost/process/process_handle.hpp
Normal file
1
include/boost/process/process_handle.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/process_handle.hpp>
|
||||
@@ -1,92 +1 @@
|
||||
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
|
||||
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
|
||||
// Copyright (c) 2009 Boris Schaeling
|
||||
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
|
||||
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
|
||||
// Copyright (c) 2016 Klemens D. Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_PROCESS_SHELL_PATH_HPP
|
||||
#define BOOST_PROCESS_SHELL_PATH_HPP
|
||||
|
||||
#include <boost/process/detail/config.hpp>
|
||||
#include <boost/process/detail/traits/wchar_t.hpp>
|
||||
|
||||
#if defined(BOOST_POSIX_API)
|
||||
#include <boost/process/detail/posix/shell_path.hpp>
|
||||
#elif defined(BOOST_WINDOWS_API)
|
||||
#include <boost/process/detail/windows/shell_path.hpp>
|
||||
#endif
|
||||
|
||||
/** \file boost/process/shell.hpp
|
||||
*
|
||||
* Header which provides the shell property. This provides the
|
||||
* property to launch a process through the system shell.
|
||||
* It also allows the user to obtain the shell-path via shell().
|
||||
\xmlonly
|
||||
<programlisting>
|
||||
namespace boost {
|
||||
namespace process {
|
||||
<emphasis>unspecified</emphasis> <globalname alt="boost::process::shell">shell</globalname>;
|
||||
}
|
||||
}
|
||||
</programlisting>
|
||||
\endxmlonly
|
||||
|
||||
*/
|
||||
|
||||
namespace boost { namespace process { namespace detail {
|
||||
|
||||
|
||||
struct shell_
|
||||
{
|
||||
constexpr shell_() {}
|
||||
|
||||
boost::filesystem::path operator()() const
|
||||
{
|
||||
return boost::process::detail::api::shell_path();
|
||||
}
|
||||
boost::filesystem::path operator()(std::error_code & ec) const noexcept
|
||||
{
|
||||
return boost::process::detail::api::shell_path(ec);
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct is_wchar_t<shell_> : is_wchar_t<boost::filesystem::path>
|
||||
{
|
||||
};
|
||||
|
||||
}
|
||||
/**
|
||||
The shell property enables to launch a program through the shell of the system.
|
||||
|
||||
\code{.cpp}
|
||||
system("gcc", shell);
|
||||
\endcode
|
||||
|
||||
The shell argument goes without any expression. The operator() is overloaded, to
|
||||
obtain the path of the system shell.
|
||||
|
||||
\code{.cpp}
|
||||
auto shell_cmd = shell();
|
||||
//avoid exceptions
|
||||
std::error_code ec;
|
||||
shell_cmd = shell(ec);
|
||||
\endcode
|
||||
|
||||
\attention Launching through the shell will NOT provide proper error handling, i.e.
|
||||
you will get an error via the return code.
|
||||
|
||||
\attention Executing shell commands that incorporate unsanitized input from an untrusted source makes a program vulnerable to shell injection, a serious security flaw which can result in arbitrary command execution. For this reason, the use of `shell` is strongly discouraged in cases where the command string is constructed from external input:
|
||||
|
||||
*/
|
||||
constexpr ::boost::process::detail::shell_ shell;
|
||||
|
||||
}}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#include <boost/process/v2/shell.hpp>
|
||||
|
||||
@@ -1,111 +1 @@
|
||||
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
|
||||
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
|
||||
// Copyright (c) 2009 Boris Schaeling
|
||||
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
|
||||
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_PROCESS_START_IN_DIR_HPP
|
||||
#define BOOST_PROCESS_START_IN_DIR_HPP
|
||||
|
||||
#include <boost/process/detail/config.hpp>
|
||||
#include <boost/process/detail/handler.hpp>
|
||||
#include <boost/process/locale.hpp>
|
||||
#include <boost/process/detail/traits/wchar_t.hpp>
|
||||
|
||||
#if defined (BOOST_POSIX_API)
|
||||
#include <boost/process/detail/posix/start_dir.hpp>
|
||||
#elif defined (BOOST_WINDOWS_API)
|
||||
#include <boost/process/detail/windows/start_dir.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/process/detail/config.hpp>
|
||||
#include <string>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
/** \file boost/process/start_dir.hpp
|
||||
*
|
||||
Header which provides the start_dir property, which allows to set the directory
|
||||
the process shall be started in.
|
||||
\xmlonly
|
||||
<programlisting>
|
||||
namespace boost {
|
||||
namespace process {
|
||||
<emphasis>unspecified</emphasis> <globalname alt="boost::process::start_dir">start_dir</globalname>;
|
||||
}
|
||||
}
|
||||
</programlisting>
|
||||
\endxmlonly
|
||||
|
||||
*/
|
||||
|
||||
namespace boost { namespace process { namespace detail {
|
||||
|
||||
struct start_dir_
|
||||
{
|
||||
constexpr start_dir_() {};
|
||||
|
||||
template<typename Char>
|
||||
api::start_dir_init<Char> operator()(const std::basic_string<Char> & st) const {return {st}; }
|
||||
template<typename Char>
|
||||
api::start_dir_init<Char> operator()(std::basic_string<Char> && s) const {return {std::move(s)}; }
|
||||
template<typename Char>
|
||||
api::start_dir_init<Char> operator()(const Char* s) const {return {s}; }
|
||||
api::start_dir_init<typename boost::filesystem::path::value_type>
|
||||
operator()(const boost::filesystem::path & st) const {return {st.native()}; }
|
||||
|
||||
template<typename Char>
|
||||
api::start_dir_init<Char> operator= (const std::basic_string<Char> & st) const {return {st}; }
|
||||
template<typename Char>
|
||||
api::start_dir_init<Char> operator= (std::basic_string<Char> && s) const {return {std::move(s)}; }
|
||||
template<typename Char>
|
||||
api::start_dir_init<Char> operator= (const Char* s) const {return {s}; }
|
||||
api::start_dir_init<typename boost::filesystem::path::value_type>
|
||||
operator= (const boost::filesystem::path & st) const {return {st.native()}; }
|
||||
|
||||
};
|
||||
|
||||
template<> struct is_wchar_t<api::start_dir_init<wchar_t>> : std::true_type {};
|
||||
|
||||
template<>
|
||||
struct char_converter<char, api::start_dir_init<wchar_t>>
|
||||
{
|
||||
static api::start_dir_init<char> conv(const api::start_dir_init<wchar_t> & in)
|
||||
{
|
||||
return api::start_dir_init<char>{::boost::process::detail::convert(in.str())};
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct char_converter<wchar_t, api::start_dir_init<char>>
|
||||
{
|
||||
static api::start_dir_init<wchar_t> conv(const api::start_dir_init<char> & in)
|
||||
{
|
||||
return api::start_dir_init<wchar_t>{::boost::process::detail::convert(in.str())};
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
To set the start dir, the `start_dir` property is provided.
|
||||
|
||||
The valid operations are the following:
|
||||
|
||||
\code{.cpp}
|
||||
start_dir=path
|
||||
start_dir(path)
|
||||
\endcode
|
||||
|
||||
It can be used with `std::string`, `std::wstring` and `boost::filesystem::path`.
|
||||
|
||||
|
||||
*/
|
||||
constexpr ::boost::process::detail::start_dir_ start_dir;
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
#include <boost/process/v2/start_dir.hpp>
|
||||
|
||||
1
include/boost/process/stdio.hpp
Normal file
1
include/boost/process/stdio.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <boost/process/v2/stdio.hpp>
|
||||
28
include/boost/process/v1.hpp
Normal file
28
include/boost/process/v1.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2024 Klemens D. Morgenstern
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
#ifndef BOOST_PROCESS_V1_HPP
|
||||
#define BOOST_PROCESS_V1_HPP
|
||||
|
||||
#include <boost/process/v1/args.hpp>
|
||||
#include <boost/process/v1/async.hpp>
|
||||
#include <boost/process/v1/async_system.hpp>
|
||||
#include <boost/process/v1/group.hpp>
|
||||
#include <boost/process/v1/child.hpp>
|
||||
#include <boost/process/v1/cmd.hpp>
|
||||
#include <boost/process/v1/env.hpp>
|
||||
#include <boost/process/v1/environment.hpp>
|
||||
#include <boost/process/v1/error.hpp>
|
||||
#include <boost/process/v1/exe.hpp>
|
||||
#include <boost/process/v1/group.hpp>
|
||||
#include <boost/process/v1/handles.hpp>
|
||||
#include <boost/process/v1/io.hpp>
|
||||
#include <boost/process/v1/pipe.hpp>
|
||||
#include <boost/process/v1/shell.hpp>
|
||||
#include <boost/process/v1/search_path.hpp>
|
||||
#include <boost/process/v1/spawn.hpp>
|
||||
#include <boost/process/v1/system.hpp>
|
||||
#include <boost/process/v1/start_dir.hpp>
|
||||
|
||||
#endif //BOOST_PROCESS_V1_HPP
|
||||
@@ -13,16 +13,16 @@
|
||||
|
||||
/** \file boost/process/args.hpp
|
||||
*
|
||||
* This header provides the \xmlonly <globalname alt="boost::process::args">args</globalname>\endxmlonly property. It also provides the
|
||||
* alternative name \xmlonly <globalname alt="boost::process::argv">argv</globalname>\endxmlonly .
|
||||
* This header provides the \xmlonly <globalname alt="boost::process::v1::args">args</globalname>\endxmlonly property. It also provides the
|
||||
* alternative name \xmlonly <globalname alt="boost::process::v1::argv">argv</globalname>\endxmlonly .
|
||||
*
|
||||
*
|
||||
\xmlonly
|
||||
<programlisting>
|
||||
namespace boost {
|
||||
namespace process {
|
||||
<emphasis>unspecified</emphasis> <globalname alt="boost::process::args">args</globalname>;
|
||||
<emphasis>unspecified</emphasis> <globalname alt="boost::process::argv">argv</globalname>;
|
||||
namespace process { BOOST_PROCESS_V1_INLINE namespace v1 {
|
||||
<emphasis>unspecified</emphasis> <globalname alt="boost::process::v1::args">args</globalname>;
|
||||
<emphasis>unspecified</emphasis> <globalname alt="boost::process::v1::argv">argv</globalname>;
|
||||
}
|
||||
}
|
||||
</programlisting>
|
||||
@@ -30,10 +30,10 @@ namespace boost {
|
||||
*/
|
||||
|
||||
|
||||
#include <boost/process/detail/basic_cmd.hpp>
|
||||
#include <boost/process/v1/detail/basic_cmd.hpp>
|
||||
#include <iterator>
|
||||
|
||||
namespace boost { namespace process { namespace detail {
|
||||
namespace boost { namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { namespace detail {
|
||||
|
||||
struct args_
|
||||
{
|
||||
@@ -138,7 +138,7 @@ struct args_
|
||||
|
||||
arg_setter_<char, true> operator()(std::initializer_list<const char*> &&range) const
|
||||
{
|
||||
return arg_setter_<char>(range.begin(), range.end());
|
||||
return arg_setter_<char, true>(range.begin(), range.end());
|
||||
}
|
||||
arg_setter_<char, true> operator+=(std::initializer_list<const char*> &&range) const
|
||||
{
|
||||
@@ -146,11 +146,11 @@ struct args_
|
||||
}
|
||||
arg_setter_<char, false> operator= (std::initializer_list<const char*> &&range) const
|
||||
{
|
||||
return arg_setter_<char, true>(range.begin(), range.end());
|
||||
return arg_setter_<char, false>(range.begin(), range.end());
|
||||
}
|
||||
arg_setter_<char, true> operator()(std::initializer_list<std::string> &&range) const
|
||||
{
|
||||
return arg_setter_<char>(range.begin(), range.end());
|
||||
return arg_setter_<char, true>(range.begin(), range.end());
|
||||
}
|
||||
arg_setter_<char, true> operator+=(std::initializer_list<std::string> &&range) const
|
||||
{
|
||||
@@ -158,12 +158,12 @@ struct args_
|
||||
}
|
||||
arg_setter_<char, false> operator= (std::initializer_list<std::string> &&range) const
|
||||
{
|
||||
return arg_setter_<char, true>(range.begin(), range.end());
|
||||
return arg_setter_<char, false>(range.begin(), range.end());
|
||||
}
|
||||
|
||||
arg_setter_<wchar_t, true> operator()(std::initializer_list<const wchar_t*> &&range) const
|
||||
{
|
||||
return arg_setter_<wchar_t>(range.begin(), range.end());
|
||||
return arg_setter_<wchar_t, true>(range.begin(), range.end());
|
||||
}
|
||||
arg_setter_<wchar_t, true> operator+=(std::initializer_list<const wchar_t*> &&range) const
|
||||
{
|
||||
@@ -171,11 +171,11 @@ struct args_
|
||||
}
|
||||
arg_setter_<wchar_t, false> operator= (std::initializer_list<const wchar_t*> &&range) const
|
||||
{
|
||||
return arg_setter_<wchar_t, true>(range.begin(), range.end());
|
||||
return arg_setter_<wchar_t, false>(range.begin(), range.end());
|
||||
}
|
||||
arg_setter_<wchar_t, true> operator()(std::initializer_list<std::wstring> &&range) const
|
||||
{
|
||||
return arg_setter_<wchar_t>(range.begin(), range.end());
|
||||
return arg_setter_<wchar_t, true>(range.begin(), range.end());
|
||||
}
|
||||
arg_setter_<wchar_t, true> operator+=(std::initializer_list<std::wstring> &&range) const
|
||||
{
|
||||
@@ -183,7 +183,7 @@ struct args_
|
||||
}
|
||||
arg_setter_<wchar_t, false> operator= (std::initializer_list<std::wstring> &&range) const
|
||||
{
|
||||
return arg_setter_<wchar_t, true>(range.begin(), range.end());
|
||||
return arg_setter_<wchar_t, false>(range.begin(), range.end());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -268,12 +268,12 @@ spawn("gcc", args+={"--version"});
|
||||
|
||||
|
||||
*/
|
||||
constexpr boost::process::detail::args_ args{};
|
||||
constexpr boost::process::v1::detail::args_ args{};
|
||||
|
||||
///Alias for \xmlonly <globalname alt="boost::process::args">args</globalname> \endxmlonly .
|
||||
constexpr boost::process::detail::args_ argv{};
|
||||
///Alias for \xmlonly <globalname alt="boost::process::v1::args">args</globalname> \endxmlonly .
|
||||
constexpr boost::process::v1::detail::args_ argv{};
|
||||
|
||||
|
||||
}}
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
/** \file boost/process/async.hpp
|
||||
|
||||
The header which provides the basic asynchrounous features.
|
||||
The header which provides the basic asynchronous features.
|
||||
It provides the on_exit property, which allows callbacks when the process exits.
|
||||
It also implements the necessary traits for passing an boost::asio::io_context,
|
||||
which is needed for asynchronous communication.
|
||||
@@ -17,8 +17,10 @@ into the boost::process namespace for convenience.
|
||||
<programlisting>
|
||||
namespace boost {
|
||||
namespace process {
|
||||
<emphasis>unspecified</emphasis> <ulink url="http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/reference/buffer.html">buffer</ulink>;
|
||||
<emphasis>unspecified</emphasis> <globalname alt="boost::process::on_exit">on_exit</globalname>;
|
||||
namespace v1 {
|
||||
<emphasis>unspecified</emphasis> <ulink url="http://www.boost.org/doc/libs/1_61_0/doc/html/boost_asio/reference/buffer.html">buffer</ulink>;
|
||||
<emphasis>unspecified</emphasis> <globalname alt="boost::process::v1::on_exit">on_exit</globalname>;
|
||||
}
|
||||
}
|
||||
}
|
||||
</programlisting>
|
||||
@@ -29,8 +31,8 @@ namespace boost {
|
||||
#ifndef BOOST_PROCESS_ASYNC_HPP_
|
||||
#define BOOST_PROCESS_ASYNC_HPP_
|
||||
|
||||
#include <boost/process/detail/traits.hpp>
|
||||
#include <boost/process/detail/on_exit.hpp>
|
||||
#include <boost/process/v1/detail/traits.hpp>
|
||||
#include <boost/process/v1/detail/on_exit.hpp>
|
||||
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/streambuf.hpp>
|
||||
@@ -39,19 +41,19 @@ namespace boost {
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
|
||||
#if defined(BOOST_POSIX_API)
|
||||
#include <boost/process/detail/posix/io_context_ref.hpp>
|
||||
#include <boost/process/detail/posix/async_in.hpp>
|
||||
#include <boost/process/detail/posix/async_out.hpp>
|
||||
#include <boost/process/detail/posix/on_exit.hpp>
|
||||
#include <boost/process/v1/detail/posix/io_context_ref.hpp>
|
||||
#include <boost/process/v1/detail/posix/async_in.hpp>
|
||||
#include <boost/process/v1/detail/posix/async_out.hpp>
|
||||
#include <boost/process/v1/detail/posix/on_exit.hpp>
|
||||
|
||||
#elif defined(BOOST_WINDOWS_API)
|
||||
#include <boost/process/detail/windows/io_context_ref.hpp>
|
||||
#include <boost/process/detail/windows/async_in.hpp>
|
||||
#include <boost/process/detail/windows/async_out.hpp>
|
||||
#include <boost/process/detail/windows/on_exit.hpp>
|
||||
#include <boost/process/v1/detail/windows/io_context_ref.hpp>
|
||||
#include <boost/process/v1/detail/windows/async_in.hpp>
|
||||
#include <boost/process/v1/detail/windows/async_out.hpp>
|
||||
#include <boost/process/v1/detail/windows/on_exit.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost { namespace process { namespace detail {
|
||||
namespace boost { namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { namespace detail {
|
||||
|
||||
struct async_tag;
|
||||
|
||||
@@ -109,10 +111,10 @@ with `function` being a callable object with the signature `(int, const std::err
|
||||
\code{.cpp}
|
||||
io_context ios;
|
||||
|
||||
child c("ls", on_exit=[](int exit, const std::error_code& ec_in){});
|
||||
child c("ls", ios, on_exit=[](int exit, const std::error_code& ec_in){});
|
||||
|
||||
std::future<int> exit_code;
|
||||
chlid c2("ls", on_exit=exit_code);
|
||||
child c2("ls", ios, on_exit=exit_code);
|
||||
|
||||
\endcode
|
||||
|
||||
@@ -122,10 +124,10 @@ chlid c2("ls", on_exit=exit_code);
|
||||
same restrictions as that class (do not register a handler for `SIGCHLD` except by using
|
||||
`boost::asio::signal_set`).
|
||||
*/
|
||||
constexpr static ::boost::process::detail::on_exit_ on_exit{};
|
||||
constexpr static ::boost::process::v1::detail::on_exit_ on_exit{};
|
||||
#endif
|
||||
|
||||
}}
|
||||
}}}
|
||||
|
||||
|
||||
|
||||
@@ -12,21 +12,21 @@
|
||||
#define BOOST_PROCESS_ASYNC_PIPE_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/process/detail/config.hpp>
|
||||
#include <boost/process/v1/detail/config.hpp>
|
||||
|
||||
#if defined(BOOST_POSIX_API)
|
||||
#include <boost/process/detail/posix/async_pipe.hpp>
|
||||
#include <boost/process/v1/detail/posix/async_pipe.hpp>
|
||||
#elif defined(BOOST_WINDOWS_API)
|
||||
#include <boost/process/detail/windows/async_pipe.hpp>
|
||||
#include <boost/process/v1/detail/windows/async_pipe.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost { namespace process {
|
||||
namespace boost { namespace process { BOOST_PROCESS_V1_INLINE namespace v1 {
|
||||
|
||||
|
||||
#if defined(BOOST_PROCESS_DOXYGEN)
|
||||
|
||||
|
||||
/** Class implementing and asnychronous I/O-Object for use with boost.asio.
|
||||
/** Class implementing an asynchronous I/O-Object for use with boost.asio.
|
||||
* It is based on the corresponding I/O Object, that is either boost::asio::windows::stream_handle or
|
||||
* boost::asio::posix::stream_descriptor.
|
||||
*
|
||||
@@ -47,6 +47,8 @@ public:
|
||||
*/
|
||||
typedef platform_specific handle_type;
|
||||
|
||||
typedef typename handle_type::executor_type executor_type;
|
||||
|
||||
/** Construct a new async_pipe, does automatically open the pipe.
|
||||
* Initializes source and sink with the same io_context.
|
||||
* @note Windows creates a named pipe here, where the name is automatically generated.
|
||||
@@ -204,11 +206,11 @@ public:
|
||||
};
|
||||
|
||||
#else
|
||||
using ::boost::process::detail::api::async_pipe;
|
||||
using ::boost::process::v1::detail::api::async_pipe;
|
||||
#endif
|
||||
|
||||
|
||||
}}
|
||||
}}}
|
||||
|
||||
|
||||
|
||||
@@ -11,17 +11,17 @@
|
||||
/**
|
||||
* \file boost/process/async_system.hpp
|
||||
*
|
||||
* Defines the asynchrounous version of the system function.
|
||||
* Defines the asynchronous version of the system function.
|
||||
*/
|
||||
|
||||
#ifndef BOOST_PROCESS_ASYNC_SYSTEM_HPP
|
||||
#define BOOST_PROCESS_ASYNC_SYSTEM_HPP
|
||||
|
||||
#include <boost/process/detail/config.hpp>
|
||||
#include <boost/process/async.hpp>
|
||||
#include <boost/process/child.hpp>
|
||||
#include <boost/process/detail/async_handler.hpp>
|
||||
#include <boost/process/detail/execute_impl.hpp>
|
||||
#include <boost/process/v1/detail/config.hpp>
|
||||
#include <boost/process/v1/async.hpp>
|
||||
#include <boost/process/v1/child.hpp>
|
||||
#include <boost/process/v1/detail/async_handler.hpp>
|
||||
#include <boost/process/v1/detail/execute_impl.hpp>
|
||||
#include <type_traits>
|
||||
#include <memory>
|
||||
#include <boost/asio/async_result.hpp>
|
||||
@@ -30,20 +30,19 @@
|
||||
#include <tuple>
|
||||
|
||||
#if defined(BOOST_POSIX_API)
|
||||
#include <boost/process/posix.hpp>
|
||||
#include <boost/process/v1/posix.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace process {
|
||||
namespace process { BOOST_PROCESS_V1_INLINE namespace v1 {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<typename ExitHandler>
|
||||
struct async_system_handler : ::boost::process::detail::api::async_handler
|
||||
template<typename Handler>
|
||||
struct async_system_handler : ::boost::process::v1::detail::api::async_handler
|
||||
{
|
||||
boost::asio::io_context & ios;
|
||||
boost::asio::async_completion<
|
||||
ExitHandler, void(boost::system::error_code, int)> init;
|
||||
Handler handler;
|
||||
|
||||
#if defined(BOOST_POSIX_API)
|
||||
bool errored = false;
|
||||
@@ -52,9 +51,8 @@ struct async_system_handler : ::boost::process::detail::api::async_handler
|
||||
template<typename ExitHandler_>
|
||||
async_system_handler(
|
||||
boost::asio::io_context & ios,
|
||||
ExitHandler_ && exit_handler) : ios(ios), init(exit_handler)
|
||||
ExitHandler_ && exit_handler) : ios(ios), handler(std::forward<ExitHandler_>(exit_handler))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -64,21 +62,15 @@ struct async_system_handler : ::boost::process::detail::api::async_handler
|
||||
#if defined(BOOST_POSIX_API)
|
||||
errored = true;
|
||||
#endif
|
||||
auto & h = init.completion_handler;
|
||||
auto h = std::make_shared<Handler>(std::move(handler));
|
||||
boost::asio::post(
|
||||
ios.get_executor(),
|
||||
[h, ec]() mutable
|
||||
{
|
||||
h(boost::system::error_code(ec.value(), boost::system::system_category()), -1);
|
||||
(*h)(boost::system::error_code(ec.value(), boost::system::system_category()), -1);
|
||||
});
|
||||
}
|
||||
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE(ExitHandler, void (boost::system::error_code, int))
|
||||
get_result()
|
||||
{
|
||||
return init.result.get();
|
||||
}
|
||||
|
||||
template<typename Executor>
|
||||
std::function<void(int, const std::error_code&)> on_exit_handler(Executor&)
|
||||
{
|
||||
@@ -86,10 +78,10 @@ struct async_system_handler : ::boost::process::detail::api::async_handler
|
||||
if (errored)
|
||||
return [](int , const std::error_code &){};
|
||||
#endif
|
||||
auto & h = init.completion_handler;
|
||||
auto h = std::make_shared<Handler>(std::move(handler));
|
||||
return [h](int exit_code, const std::error_code & ec) mutable
|
||||
{
|
||||
h(boost::system::error_code(ec.value(), boost::system::system_category()), exit_code);
|
||||
(*h)(boost::system::error_code(ec.value(), boost::system::system_category()), exit_code);
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -116,29 +108,44 @@ the return value (from the second parameter, `exit_handler`).
|
||||
*/
|
||||
#if defined(BOOST_PROCESS_DOXYGEN)
|
||||
template<typename ExitHandler, typename ...Args>
|
||||
inline boost::process::detail::dummy
|
||||
inline boost::process::v1::detail::dummy
|
||||
async_system(boost::asio::io_context & ios, ExitHandler && exit_handler, Args && ...args);
|
||||
#endif
|
||||
|
||||
namespace detail
|
||||
{
|
||||
struct async_system_init_op
|
||||
{
|
||||
|
||||
template<typename Handler, typename ... Args>
|
||||
void operator()(Handler && handler, asio::io_context & ios, Args && ... args)
|
||||
{
|
||||
detail::async_system_handler<typename std::decay<Handler>::type> async_h{ios, std::forward<Handler>(handler)};
|
||||
child(ios, std::forward<Args>(args)..., async_h ).detach();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
template<typename ExitHandler, typename ...Args>
|
||||
inline BOOST_ASIO_INITFN_RESULT_TYPE(ExitHandler, void (boost::system::error_code, int))
|
||||
async_system(boost::asio::io_context & ios, ExitHandler && exit_handler, Args && ...args)
|
||||
{
|
||||
detail::async_system_handler<ExitHandler> async_h{ios, std::forward<ExitHandler>(exit_handler)};
|
||||
|
||||
typedef typename ::boost::process::detail::has_error_handler<boost::fusion::tuple<Args...>>::type
|
||||
|
||||
typedef typename ::boost::process::v1::detail::has_error_handler<boost::fusion::tuple<Args...>>::type
|
||||
has_err_handling;
|
||||
|
||||
static_assert(!has_err_handling::value, "async_system cannot have custom error handling");
|
||||
|
||||
|
||||
child(ios, std::forward<Args>(args)..., async_h ).detach();
|
||||
|
||||
return async_h.get_result();
|
||||
return boost::asio::async_initiate<ExitHandler, void (boost::system::error_code, int)>(
|
||||
detail::async_system_init_op{}, exit_handler, ios, std::forward<Args>(args)...
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}}
|
||||
#endif
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -17,29 +17,29 @@
|
||||
#ifndef BOOST_PROCESS_CHILD_HPP
|
||||
#define BOOST_PROCESS_CHILD_HPP
|
||||
|
||||
#include <boost/process/detail/config.hpp>
|
||||
#include <boost/process/detail/child_decl.hpp>
|
||||
#include <boost/process/detail/execute_impl.hpp>
|
||||
#include <boost/process/v1/detail/config.hpp>
|
||||
#include <boost/process/v1/detail/child_decl.hpp>
|
||||
#include <boost/process/v1/detail/execute_impl.hpp>
|
||||
|
||||
#if defined(BOOST_POSIX_API)
|
||||
#include <boost/process/posix.hpp>
|
||||
#include <boost/process/v1/posix.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
///The main namespace of boost.process.
|
||||
namespace process {
|
||||
namespace process { BOOST_PROCESS_V1_INLINE namespace v1 {
|
||||
|
||||
template<typename ...Args>
|
||||
child::child(Args&&...args)
|
||||
: child(::boost::process::detail::execute_impl(std::forward<Args>(args)...)) {}
|
||||
: child(::boost::process::v1::detail::execute_impl(std::forward<Args>(args)...)) {}
|
||||
|
||||
|
||||
///Typedef for the type of an pid_t
|
||||
typedef ::boost::process::detail::api::pid_t pid_t;
|
||||
typedef ::boost::process::v1::detail::api::pid_t pid_t;
|
||||
|
||||
#if defined(BOOST_PROCESS_DOXYGEN)
|
||||
/** The main class to hold a child process. It is simliar to [std::thread](http://en.cppreference.com/w/cpp/thread/thread),
|
||||
/** The main class to hold a child process. It is similar to [std::thread](http://en.cppreference.com/w/cpp/thread/thread),
|
||||
* in that it has a join and detach function.
|
||||
*
|
||||
* @attention The destructor will call terminate on the process if not joined or detached without any warning.
|
||||
@@ -128,7 +128,7 @@ class child
|
||||
/** Same as valid, for convenience. */
|
||||
explicit operator bool() const;
|
||||
|
||||
/** Check if the the chlid process is in any process group. */
|
||||
/** Check if the the child process is in any process group. */
|
||||
bool in_group() const;
|
||||
|
||||
/** \overload bool in_group() const */
|
||||
@@ -149,6 +149,6 @@ class child
|
||||
|
||||
#endif
|
||||
|
||||
}}
|
||||
}}}
|
||||
#endif
|
||||
|
||||
@@ -12,43 +12,42 @@
|
||||
#define BOOST_PROCESS_DETAIL_CMD_LINE_HPP
|
||||
|
||||
#include <boost/winapi/config.hpp>
|
||||
#include <boost/process/detail/config.hpp>
|
||||
#include <boost/process/detail/handler_base.hpp>
|
||||
#include <boost/process/detail/traits/cmd_or_exe.hpp>
|
||||
#include <boost/process/detail/traits/wchar_t.hpp>
|
||||
#include <boost/process/v1/detail/config.hpp>
|
||||
#include <boost/process/v1/detail/handler_base.hpp>
|
||||
#include <boost/process/v1/detail/traits/cmd_or_exe.hpp>
|
||||
#include <boost/process/v1/detail/traits/wchar_t.hpp>
|
||||
|
||||
#if defined(BOOST_POSIX_API)
|
||||
#include <boost/process/detail/posix/cmd.hpp>
|
||||
#include <boost/process/v1/detail/posix/cmd.hpp>
|
||||
#elif defined(BOOST_WINDOWS_API)
|
||||
#include <boost/process/detail/windows/cmd.hpp>
|
||||
#include <boost/process/v1/detail/windows/cmd.hpp>
|
||||
#endif
|
||||
|
||||
/** \file boost/process/cmd.hpp
|
||||
*
|
||||
* This header provides the \xmlonly <globalname alt="boost::process::cmd">cmd</globalname>\endxmlonly property.
|
||||
* This header provides the \xmlonly <globalname alt="boost::process::v1::cmd">cmd</globalname>\endxmlonly property.
|
||||
*
|
||||
\xmlonly
|
||||
<programlisting>
|
||||
namespace boost {
|
||||
namespace process {
|
||||
<emphasis>unspecified</emphasis> <globalname alt="boost::process::cmd">cmd</globalname>;
|
||||
namespace process { BOOST_PROCESS_V1_INLINE namespace v1 {
|
||||
<emphasis>unspecified</emphasis> <globalname alt="boost::process::v1::cmd">cmd</globalname>;
|
||||
}
|
||||
}
|
||||
</programlisting>
|
||||
\endxmlonly
|
||||
*/
|
||||
|
||||
namespace boost { namespace process { namespace detail {
|
||||
namespace boost { namespace process { BOOST_PROCESS_V1_INLINE namespace v1 { namespace detail {
|
||||
|
||||
|
||||
struct cmd_
|
||||
{
|
||||
constexpr cmd_() {}
|
||||
constexpr cmd_() = default;
|
||||
|
||||
template<typename Char>
|
||||
inline api::cmd_setter_<Char> operator()(const Char *s) const
|
||||
{
|
||||
return api::cmd_setter_<Char>(s);
|
||||
{ return api::cmd_setter_<Char>(s);
|
||||
}
|
||||
template<typename Char>
|
||||
inline api::cmd_setter_<Char> operator= (const Char *s) const
|
||||
@@ -77,7 +76,7 @@ struct char_converter<char, api::cmd_setter_<wchar_t>>
|
||||
{
|
||||
static api::cmd_setter_<char> conv(const api::cmd_setter_<wchar_t> & in)
|
||||
{
|
||||
return { ::boost::process::detail::convert(in.str()) };
|
||||
return { ::boost::process::v1::detail::convert(in.str()) };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -86,7 +85,7 @@ struct char_converter<wchar_t, api::cmd_setter_<char>>
|
||||
{
|
||||
static api::cmd_setter_<wchar_t> conv(const api::cmd_setter_<char> & in)
|
||||
{
|
||||
return { ::boost::process::detail::convert(in.str()) };
|
||||
return { ::boost::process::v1::detail::convert(in.str()) };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -115,8 +114,8 @@ The property can only be used for assignments.
|
||||
|
||||
|
||||
*/
|
||||
constexpr static ::boost::process::detail::cmd_ cmd;
|
||||
constexpr static ::boost::process::v1::detail::cmd_ cmd;
|
||||
|
||||
}}
|
||||
}}}
|
||||
|
||||
#endif
|
||||
@@ -11,26 +11,26 @@
|
||||
#include <type_traits>
|
||||
|
||||
#if defined(BOOST_POSIX_API)
|
||||
#include <boost/process/posix.hpp>
|
||||
#include <boost/process/detail/posix/async_handler.hpp>
|
||||
#include <boost/process/detail/posix/asio_fwd.hpp>
|
||||
#include <boost/process/v1/posix.hpp>
|
||||
#include <boost/process/v1/detail/posix/async_handler.hpp>
|
||||
#include <boost/process/v1/detail/posix/asio_fwd.hpp>
|
||||
#else
|
||||
#include <boost/process/detail/windows/async_handler.hpp>
|
||||
#include <boost/process/detail/windows/asio_fwd.hpp>
|
||||
#include <boost/process/v1/detail/windows/async_handler.hpp>
|
||||
#include <boost/process/v1/detail/windows/asio_fwd.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace process {
|
||||
namespace process { BOOST_PROCESS_V1_INLINE namespace v1 {
|
||||
|
||||
namespace detail {
|
||||
|
||||
#if defined(BOOST_POSIX_API)
|
||||
using ::boost::process::detail::posix::is_async_handler;
|
||||
using ::boost::process::detail::posix::does_require_io_context;
|
||||
using ::boost::process::v1::detail::posix::is_async_handler;
|
||||
using ::boost::process::v1::detail::posix::does_require_io_context;
|
||||
#else
|
||||
using ::boost::process::detail::windows::is_async_handler;
|
||||
using ::boost::process::detail::windows::does_require_io_context;
|
||||
using ::boost::process::v1::detail::windows::is_async_handler;
|
||||
using ::boost::process::v1::detail::windows::does_require_io_context;
|
||||
#endif
|
||||
|
||||
template<typename ...Args>
|
||||
@@ -112,6 +112,7 @@ boost::asio::io_context &get_io_context_var(First&, Args&...args)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif /* BOOST_PROCESS_DETAIL_ASYNC_HANDLER_HPP_ */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user