Re: Closing XTerm causes the GTK app to exit, inspite of disown/nohup on its PID - why?

2019-03-06 Thread Veek M via gtk-list
thank you, SIGINT was the culprit.
trap "echo HUP>>/tmp/err" SIGHUP
trap "echo QUIT>>/tmp/err" SIGQUIT
trap "echo INT>>/tmp/err" SIGINT
trap "echo TERM >>/tmp/err" SIGTERM

revealed all
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: Closing XTerm causes the GTK app to exit, inspite of disown/nohup on its PID - why?

2019-03-05 Thread James Cameron
Wild guess; use strace to look for a signal at the time the window is
closed, and add code to replace the handler for the signal.

For instance, to handle Ctrl+C gracefully in Python that uses GTK,
some of my code does this;

GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, callback)

-- 
James Cameron
http://quozl.netrek.org/
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Closing XTerm causes the GTK app to exit, inspite of disown/nohup on its PID - why?

2019-03-05 Thread Veek M via gtk-list
https://www.reddit.com/r/bash/comments/axi4n6/closing_xterm_causes_the_app_to_exit_inspite_of/

Adding nohup works but ONLY for xclock xfontsel xpdf - hexchat and
firefox exit when the terminal exits - basically GTK apps.

Script creates a named-pipe .Xauthority to pass MIT-MAGIC-cookie data
to a app running as X_USER. It works great but I'm unable to detach
the process from its XTerm. Closing XTerm closes the app.

I want to use an XTerm because it supports -hold (for debugging) if
there's a problem I can insert a -hold to view the error message.

#!/usr/bin/bash
#Usage: bash run appname

set +xv

X_USER=veek
DIR_X_USER=/home/veek


function error
{
echo "$@" >>/tmp/error.$0
}

function create_fifo
{
error $FUNCNAME[0];
mkfifo ${DIR_X_USER}/.Xauthority;
chown $USER:$USER ${DIR_X_USER}/.Xauthority
}


getopts k myarg

case $myarg in
k) pkill -KILL -u ${X_USER}; shift;;
*) if [ $# -lt 1 ]; then
echo "Usage: $0 [-k] app_name";
exit 1;
   fi;;
esac

declare -A myapp_list=( [ff]=firefox
[hex]=hexchat
[pdf]='wine .wine/drive_c/Program Files/Tracker Software/PDF
Viewer/PDFXCview.exe' )

case $1 in
pdf*) set ${myapp_list[$1]%% *} "${myapp_list[$1]#[a-z]* }";;
*) set ${myapp_list[$1]:-"$@"};;
esac

[ ! -O ${DIR_X_USER}/.Xauthority ] && {
error $FUNCNAME[0];
rm ${DIR_X_USER}/.Xauthority;
create_fifo;
}
[ -f ${DIR_X_USER}/.Xauthority ] && {
error $FUNCNAME[0]; exit
exit 1;
}
[ ! -p ${DIR_X_USER}/.Xauthority ] && {
error $FUNCNAME[0];
create_fifo;
}

if [ -p ${DIR_X_USER}/.Xauthority ]; then
xterm -geometry -0-0 -T 'sudoAuth' -e bash -c '
if mkdir -v /tmp/fe.lock; then
echo "start"; trap "rm -rf /tmp/fe.lock/" 0
declare -g count=0
while true; do
#blocks waiting for an app to read fifo
cat ~/.Xauthority >>$1/.Xauthority;
echo $((count = count + 1)) ;
done
else
exit 0
fi
' junk_txt "${DIR_X_USER}"&
fi


#xterm -e "su - ${X_USER} -c 'export XAUTHORITY=~/.Xauthority; hexchat'"
#-hold to see the XTerm error msg
xterm -T "$1" -e sudo -u "${X_USER}" bash -c '
export DISPLAY=:0.0
export XAUTHORITY=/home/veek/.Xauthority
progname="$1"; shift;
cd;
if [ ${#1} -gt 0 ]; then
echo two args
nohup "$progname" "$1"&
else
nohup "$progname"&
fi
for pid in $(jobs -p); do
echo $pid
disown $pid
done
echo done
sleep 40' junk_txt "$1" "$2"&
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list