operating system - Signal handling in shell script -


i want processes blocked custom user signal , when signal arrives should wake waiting process in shell script?need steps coding can take care of?

if signal wish send signal number 17, might use:

trap ":" 17 sleep 1000000 trap 17 # ...what want happen after signal received... 

the first trap command execute quoted command (:) when signal received. : command nothing. however, can't use trap "" 17 means 'ignore signal 17', opposite of want.

the sleep 1000000 way nothing long time without using cpu resource.

the second trap cancels signal handling signal 17, reinstating default behaviour.

after that, can put whatever code want executed once signal received.


instead of using sleep, might prefer create , use program, pause, waits indefinitely (rather risk sleep waking before signal received). use trivial program:

#include <unistd.h>  int main(void) {     pause();     return(0); } 

as point of detail, return won't executed; signal force program terminate before pause() returns errno == eintr.


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -