On RHEL 7.4.
We are using Citrix VDA to start a UNIX desktop session for our application. The session is only the application, so when it closes, the VDA session exits (Citrix XenApp).
The problem is if the application core dumps, we want start a background job to evaluate the core file with gdb, gather & compress cores and log files, and send an email to the support staff with the results. But we don't want to keep the users' foreground session held this entire time (it can take minutes), so I'm trying to run this as a background job.
But every attempt using nohup, or a customized daemonized c programs (following all the standard daemon standard practices), etc all fail to keep the process running after the X session closes out. I believe the problem is that the session is built up with dbus-launch, and while I don't fully understand all its inner workings, it seems to be feature that it cleans up everything on its exit; if so, its doing its job.
So how can I keep a job running after logout?
Here is a simple but representative process tree of a session:
ps -fju 26811
UID PID PPID PGID SID C STIME TTY TIME CMD
545165 4653 4597 4597 4597 0 14:37 ? 00:00:00 /opt/Citrix/VDA/bin/ctxlogin -display :320
545165 4669 4653 4597 4597 0 14:37 ? 00:00:00 /bin/bash /opt/Citrix/VDA/bin/ctxsession.sh
545165 4773 1 4597 4597 0 14:37 ? 00:00:00 dbus-launch --sh-syntax --exit-with-session
545165 4774 1 4774 4774 0 14:37 ? 00:00:00 /bin/dbus-daemon --fork --print-pid 4 --print-address 6 --session
545165 4783 1 4774 4774 0 14:37 ? 00:00:00 /usr/libexec/dconf-service
545165 4818 4669 4597 4597 0 14:37 ? 00:00:00 /opt/Citrix/VDA/bin/ctxctl
545165 4819 4669 4597 4597 0 14:37 ? 00:00:00 /opt/Citrix/VDA/bin/ctxclipboard
545165 4821 4669 4597 4597 0 14:37 ? 00:00:03 /opt/Citrix/VDA/bin/ctxaudio
545165 4822 4669 4597 4597 0 14:37 ? 00:00:00 /opt/Citrix/VDA/bin/ctxlpmngt
545165 4824 4669 4597 4597 0 14:37 ? 00:00:05 /usr/bin/mutter
545165 4825 4669 4597 4597 0 14:37 ? 00:00:00 /opt/Citrix/VDA/bin/ctxtwi 16 4824
545165 4871 1 4870 4870 0 14:37 ? 00:00:00 /usr/bin/pulseaudio --start --log-target=syslog
545165 4894 1 4774 4774 0 14:37 ? 00:00:00 /usr/libexec/gvfsd
545165 4908 1 4774 4774 0 14:37 ? 00:00:00 /usr/libexec/at-spi-bus-launcher
545165 4915 4908 4774 4774 0 14:37 ? 00:00:00 /bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print
545165 4918 1 4774 4774 0 14:37 ? 00:00:00 /usr/libexec/at-spi2-registryd --use-gnome-session
545165 4935 4653 4597 4597 0 14:37 ? 00:00:00 xterm
545165 4973 4935 4973 4973 0 14:37 pts/2 00:00:00 bash
545165 8038 1 8038 8038 0 15:23 ? 00:00:00 ./daemonize
545165 8039 8038 8038 8038 0 15:23 ? 00:00:00 sleep 1200
545165 8052 4973 8052 4973 0 15:23 pts/2 00:00:00 ps -fju 26811
So for example I'm trying to keep the daemonize and sleep processes running after logout. It is it's own session leader, no controlling terminal. But it still closes down when the dbus-launch process exits.
If I'm on the right track, the env variable
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-mGwaZ8i3Ni,guid=57f80a3ec05a1036fe8a6e0e5d30ca6c
might be significant, but I've tried unsetting this before daemonizing, but no help.
Any thoughts of what I can do to keep my garbage gathering process running after logout?
Thanks, Brian