-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME
More file actions
41 lines (29 loc) · 1.01 KB
/
README
File metadata and controls
41 lines (29 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Programs:
sema
An utility to create, delete, raise, wait on a named semaphore. This program is distributed under the GPL version 2 license. See the file INSTALL for installation instructions.
Examples:
If one script wants to wait until another script has executed some steps, the following pattern could be used.
A.sh
_____________________________________________
#!/bin/sh
echo A.sh started
sema -c S1
./B.sh &
echo A.sh more work
echo waiting for B.sh to finish
sema -w S1
echo B.sh finished execution
echo A.sh do more work
# cleanup semaphores
sema -d S1
_____________________________________________
B.sh
_____________________________________________
#!/bin/sh
echo Hello from B.sh
sleep 5
sema -r S1
echo Bye bye from B.sh
____________________________________________
Troubleshooting:
If a shell script fails and leaves a semaphore with negative values, it is not possible to delete it. In that case, raise the value of semaphore by raising it manually by executing sema -r S1 and then delete it using sema -d S1