make process is killed before running a child process
Alright, so first things first I admit I'm probably sinning by attempting this, and it may be purely my fault, but I still want to solve this issue nevertheless. Please understand my knowledge in GNU Make is not particularly good.
When using a Makefile
using GNOME Builder's "run" button, the associated GIO job seems to kill it before subprocesses are properly closed. In particular, I made a Makefile with the following phony target:
run: out/book.pdf
xdg-open out/book.pdf
which in practice is equivalent, in my system (Debian Sid with GTK+ 3.24.1, GNOME Builder 3.30.1, GNU Make 4.2.1), to:
run: out/book.pdf
gio open out/book.pdf
Running this target on a terminal with make run
, including the VTE one embedded on GNOME Builder, it executes as expected. However, when using the proper GNOME Builder way, it gives the following output:
make: Entering directory '/project/path'
xdg-open out/book.pdf
Application exited
(gio open:8154): GLib-DEBUG: 11:58:02.219: posix_spawn avoided (automatic reaping requested) (fd close requested)
make: Leaving directory '/project/path'
(the path is purposefully different from the original log, should be irrelevant)
When trying to run the gio
command directly, a mostly equivalent log appears, except for the position of the "Application exited" message:
make: Entering directory '/project/path'
gio open out/book.pdf
(gio open:8166): GLib-DEBUG: 11:58:09.780: posix_spawn avoided (automatic reaping requested) (fd close requested)
Application exited
make: Leaving directory '/project/path'
Making sure the process tree is independent from make
's execution like this seems to patch the issue:
run: out/book.pdf
nohup xdg-open out/book.pdf >/dev/null &