Skip to content

acbits/sema

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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


About

A command line utility to manipulate named semaphores.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published