v1cont / yad

Yet Another Dialog
GNU General Public License v3.0
654 stars 58 forks source link

YAD --paned does not terminated after closing window #78

Open sarether opened 4 years ago

sarether commented 4 years ago

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.

dreamstorpi commented 4 years ago

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.

sarether commented 4 years ago

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.

v1cont commented 4 years ago

can you check the latest git?

sarether commented 4 years ago

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.

v1cont commented 4 years ago

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?

sarether commented 4 years ago

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).

v1cont commented 4 years ago

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

sarether commented 4 years ago

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

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

v1cont commented 4 years ago

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

sarether commented 4 years ago

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.

v1cont commented 4 years ago

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

sarether commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 1 year ago

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