Sample Header Ad - 728x90

How can I detach a process from a bash script?

48 votes
6 answers
102781 views
I am trying to detach a process from a bash script so that SIGINT will not be forwarded to the process when I exit the script. I have used the disown command in terminal directly, however in bash, disown does not stop SIGINT from being forwarded. The purpose of this script is to start openocd and then gdb with a single invocation. Since the script never exits (it's running gdb) SIGINT is still forwarded from gdb to openocd which is a problem since SIGINT is used as the halt command in gdb. In terminal it would look something like this: $ openocd & # run openocd demonized $ disown $! # disown last pid $ gdb # invoke GDB when invoked on terminal in this order, the SIGINT is not passed from gdb to openocd. However if this same invocation was in a bash script, the SIGINT is passed. Any help would be greatly appreciated. ps this problem is in OS X but I am trying to use tools which are also portable to all Unix tools.
Asked by user2328113 (649 rep)
Mar 14, 2016, 11:39 PM
Last activity: May 1, 2024, 02:29 PM