yad icon indicating copy to clipboard operation
yad copied to clipboard

YAD --paned does not terminated after closing window

Open sarether opened this issue 4 years ago • 15 comments

The example from the manual:

yad --plug=12345 --tabnum=1 --text="first tab with text" &> res1 &
yad --plug=12345 --tabnum=2 --text="second tab" --entry &> res2 &
yad --paned --key=12345 --tab="Tab 1" --tab="Tab 2"

and sometimes YAD is not terminated when the window is closed. There is no window, but there are YAD processes. You must manually terminate YAD, and restarting the example above YAD does not start: Unable to create shared memory for key 12345: file exists You will have to remove it: ipcrm -M 12345

YAD versions from 0.42 to 6.0.

sarether avatar May 04 '20 00:05 sarether

Yes, I have the same issue. In my case the ipcrm command doesn't work either. I have overcome the issue by issuing a "pkill yad" command when the program ends. It works.

dreamstorpi avatar May 04 '20 06:05 dreamstorpi

I have overcome the issue by issuing a "pkill yad"

In some cases this may not work and it is a kludge. I've already added such code to my script:

ysi_cleanup () {
	pkill -f "yad --plug=$randomkey"
	pkill -f "yad --paned --key=$randomkey"
	rm -rf "$ysitmp"
}
trap ysi_cleanup EXIT HUP INT QUIT TERM

but it also doesn't always work after closing YAD-paned window. From time to time YAD continues to run in the background.

sarether avatar May 04 '20 09:05 sarether

can you check the latest git?

v1cont avatar May 06 '20 20:05 v1cont

can you check the latest git?

Booted from USB stick (debian-live-10.3.0-amd64-xfce+nonfree.iso).

sudo apt-get update && sudo apt install -y git build-essential fakeroot devscripts libgtk-3-dev intltool

git clone https://github.com/v1cont/yad.git

cd yad

autoreconf -ivf && intltoolize && export CFLAGS="$CFLAGS -DBORDERS=2" && ./configure --enable-standalone --disable-tray --disable-pfd --without-rgb --disable-icon-browser && make && sudo make install-strip

Build configuratioh:
  Status icon          - no
  HTML widget          - no
  GtkSourceView        - no
  Spell checking       - no
  Path to rgb.txt      - no
  Standalone build     - yes
  pfd                  - no
  Icon browser         - no

Tested the example from the manual on Arch Linux. The problem is still present.

sarether avatar May 07 '20 16:05 sarether

i use this script for testing the problem

#! /bin/bash

while : ; do
    ./yad --plug=12345 --tabnum=1 --text="first tab with text" &> res1 &
    ./yad --plug=12345 --tabnum=2 --text="second tab" --entry &> res2 &
    ./yad --paned --key=12345 --tab="Tab 1" --tab="Tab 2" --width=800 --height=600 &
    yp=$!
    sleep 1
    kill -USR2 $yp
    sleep 1
done

all works fine for me under latest Xorg server

can you describe your environment?

v1cont avatar May 07 '20 18:05 v1cont

i use this script for testing the problem

#! /bin/bash

while : ; do
    ./yad --plug=12345 --tabnum=1 --text="first tab with text" &> res1 &
    ./yad --plug=12345 --tabnum=2 --text="second tab" --entry &> res2 &
    ./yad --paned --key=12345 --tab="Tab 1" --tab="Tab 2" --width=800 --height=600 &
    yp=$!
    sleep 1
    kill -USR2 $yp
    sleep 1
done

all works fine for me under latest Xorg server

can you describe your environment?

Current Arch Linux stuff. Xfce 4.14.1. Nothing from AUR, exept some GTK themes and icons. Try to run many times. It can work 100 times but for the first or fifth, tenth time not unloaded.

First time get (screencast ~4 MB): https://yadi.sk/i/bnwRnQElBRkmgQ

YAD compiled about 3 hours ago from Git (my previous comment).

sarether avatar May 07 '20 19:05 sarether

sorry, but yandex is blocked in ukraine. can you upload screencast to another hosting, please?

v1cont avatar May 07 '20 20:05 v1cont

https://drive.google.com/open?id=1qPmpQJz4XSeQ7LWa-fc7a0eDjGVSBdNl

Yes, with "kill -USR2" is fine. But is a kludge, isn't it?

sarether avatar May 08 '20 10:05 sarether

USR1 and USR2 signals works the same as pressing OK or Cancel buttons

v1cont avatar May 10 '20 11:05 v1cont

USR1 and USR2 signals works the same as pressing OK or Cancel buttons

OK. I fixed my script (there was incorrect trap function and I added -USR1 for killing YAD pid), but the script also uses the YAD 252 signal, so it would be nice if the paned mode didn't require other actions for termination.

Thanks for YAD and help.

sarether avatar May 10 '20 15:05 sarether

exit code 252 means that yad dialog was closed by pressing Esc. if you don't need this behavior just add --no-escape option

v1cont avatar May 11 '20 07:05 v1cont

exit code 252 means that yad dialog was closed by pressing Esc. if you don't need this behavior just add --no-escape option

I already added "--no-escape" to main paned dialog window, although this option isn't important there. I use 252 signal for restore the main window after its closing by window manager (Alt+F4, Close button etc) and calling child dialog.

sarether avatar May 11 '20 14:05 sarether

I debugged my script using "set -x", and if it stuck, then always in "yad --paned" line.

# Deleting temporary stuff after exiting
ysi_cleanup () {
kill -USR1 "$yp" 2>/dev/null
rm -rf "$ysitmp"
ipcrm -M "$rnum" 2>/dev/null
}
trap ysi_cleanup EXIT INT HUP QUIT
...
# YAD window
yad --plug ... &
yad --plug ... &
yad  --paned ... &
yp=$!
wait $yp

Could it be that the paned mode doesn't always catch/return the EXIT signal when closing YAD window by WM?

(yad:4285): Gtk-CRITICAL **: 20:27:55.981: gtk_main_quit: assertion 'main_loops != NULL' failed

sarether avatar May 29 '20 08:05 sarether

I'm using Compiz (Xfce + Metacity as decorator) and noticed that YAD hangs much more often when using Compiz. With Xfwm YAD hanged only once out of hundreds of launches in almost a month. When using Compiz or GNOME 3 (Mutter WM), hangs occur randomly, as I wrote earlier. I've never had any hangs with KDE Plasma, although I don't use KDE all the time.

sarether avatar Jul 28 '20 13:07 sarether

Sometimes YAD window respawn over "long" (few seconds) time. Maybe some cycle?

This part of code is for suspending the process:

event=$?
if [ -s "$BASE_PID" ] && [ $event -eq 252 ]; then
	kill -STOP "$(cat "$BASE_PID")"
	if yad --title="$TITLE" --width=NNNN --text="ABCD" \
	--on-top --center --image=dialog-question \
	--window-icon=$ICON \
	--button=$n!gtk-no:1 --button=$y!gtk-yes:0; then
		rm "$VAR"
		kill -KILL "$(cat "$BASE_PID")"
	else
		kill -CONT "$(cat "$BASE_PID")"
	fi
else
	break
fi

sarether avatar Nov 25 '22 10:11 sarether