Tag Info

New answers tagged

2

Try: #!/bin/bash _term() { printf "%s\n" "Caught SIGTERM signal!" kill -TERM $child 2>/dev/null } trap _term 15 echo "Doing some initial work...."; exec /bin/start/main/server --nodaemon & child=$! wait $child Normally, bash will not call trap handler when it's waiting child process. Using exec, your server will be start in a ...


0

You can kill the pid of shell (bash). I just tried and it works. Because I cannot see the process from ps -ef (the job that we run in the looping script).


0

I approve of the answer by goldilocks. But instead of using the system call read to check for filesystem changes, one can use inotify. Its man page is here and here. There is an excellent explanation and example by the creators (developers) of inotify here.


2

Usually I try to keep things as simple as: kill $pid; sleep 5; kill -9 $pid Or you can search a process by its name if you like: pkill $pattern; sleep 5; pkill -9 $pattern This is handy when you are working in a terminal, but for scripting you may prefer a more sophisticated solution from another answer.


0

Put this in your ~/.bashrc file. Use it like this killany program_name. It will try to kill any program with a matching name. killany () { PS=$(ps aux) PIDS=$(echo "$PS" | \ awk -v proc="$1" '{ reg=proc; if(match($11$12$13$14,reg)) print $2 }') if [ -n "$PIDS" ]; then echo "killing pids '$PIDS'" kill $PIDS 2> /dev/null ...


3

I can try to trap the Interrupt at a lower level and inform the gtkmm application. No, that is a kernel space activity. Fortunately, the kernel does report the outcome of certain events via interfaces accessible from userland. It's a little ambiguous in your question whether you want to detect when a block device is attached, or when a filesystem is ...



Top 50 recent answers are included