OILS / spec / ysh-builtin-process.test.sh View on Github | oilshell.org

85 lines, 56 significant
1# fork and forkwait
2
3#### fork and forkwait usage errors
4shopt --set oil:upgrade
5shopt --unset errexit
6
7fork
8echo status=$?
9
10fork extra
11echo status=$?
12
13fork extra {
14 echo hi
15}
16echo status=$?
17
18#
19
20forkwait
21echo status=$?
22
23forkwait extra
24echo status=$?
25
26forkwait extra {
27 echo hi
28}
29echo status=$?
30
31## STDOUT:
32status=2
33status=2
34status=2
35status=2
36status=2
37status=2
38## END
39
40#### forkwait
41shopt --set oil:upgrade
42shopt --unset errexit
43
44old=$PWD
45
46forkwait {
47 cd /
48 echo hi
49 exit 42
50}
51echo status=$?
52if test "$old" = "$PWD"; then
53 echo ok
54fi
55## STDOUT:
56hi
57status=42
58ok
59## END
60
61#### fork
62shopt --set oil:upgrade
63shopt --unset errexit
64
65old=$PWD
66
67fork {
68 cd /
69 echo hi
70 sleep 0.01
71 exit 42
72}
73#echo status=$? race condition
74
75wait -n
76echo status=$?
77
78if test "$old" = "$PWD"; then
79 echo ok
80fi
81## STDOUT:
82hi
83status=42
84ok
85## END