When certain text is found, the tail process is killed, the fifo closed, the application process is force killed and the temporary file deleted. Then tail is run against that file piping to a fifo. The application is run with its output piped to a temporary file. One way to do this is to launch the application from a script instead of directly. In order to ensure that the trap is also executed on failures of child processes, it needs to be inherited via set -E. If you comment the trap part out, they will remain. Now if you exit the GUI command, all sleeps will disappear. If you want to test it, I suggest using many sleeps: #!/bin/bash The GUI-program is a child of the script and also child processes of the GUI-program itself are part of the process group linked to the script as the origin. $$ is simply the PID of the current shell script. kill -9 -$pid will kill a while process group. is needed so that the following argument is not interpreted as a flag. process and all its children and forks) by adding a minus to the PID. kill may terminate a single process via kill will act on a whole process group (i.e. The command in use is kill, where -9 sends a SIGKILL. CTRL+C, or if foxit got killed by another reason). closing the GUI programm) and ERR for any error (e.g. In this case EXIT stands for a graceful exit (i.e. I believe the simplest way is to start the program via a script and establish a trap to kill the whole process group: #!/bin/bashĪ trap is a shell builtin that execute a certain command if the script receives one (or more) signals.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |