#1141530 needrestart: [PATCH] hangs in notify.d/400-notify-send at runuser(1)

#1141530#5
Date:
2026-07-05 20:12:19 UTC
From:
To:
Dear Maintainer,

Occasionally when installing new packages via apt(1) or aptitude(1), the
installation process would hang just before the end.  There would be no
error message; the terminal would simple stall for a bit and the install
would complete successfully.  The hang would happen at the time of the
blank line in the following output (tail of the output of an interactive
aptitude(1) session):

[[[
User sessions running outdated binaries:
 daniel @ session #18: cinnamon-sessio[18987]

No VM guests are running outdated hypervisor (qemu) binaries on this host.
Press Return to continue, 'q' followed by Return to quit.
]]]

ps(1) output at the time of the hang:

[[[
root      471874  0.0  0.0   2672  1780 pts/5    S+   02:31   0:00 sh -c -- test -x /usr/lib/needrestart/apt-pinvoke && /usr/lib/needrestart/apt-pinvoke || true
root      471875  0.4  0.1  31636 23340 pts/5    S+   02:31   0:00 /usr/bin/perl /usr/share/debconf/frontend /usr/sbin/needrestart
root      471888  0.7  0.1  30632 23704 pts/5    S+   02:31   0:00 /usr/bin/perl /usr/sbin/needrestart
root      471903  0.0  0.0   2672  1844 pts/5    S+   02:31   0:00 /bin/sh /etc/needrestart/notify.d/400-notify-send
root      471913  0.0  0.0  12340  4540 pts/5    S+   02:31   0:00 runuser -p -u daniel -- /usr/bin/notify-send -a needrestart -u critical -i dialog-warning Relogin or restarts required! Your session is running obsolete binaries or libraries as listed below. <i><b>Please consider a relogin or restart of the affected processes!</b></i>\ncinnamon-sessio[18987]
daniel    471914  0.0  0.0 170976  6736 pts/5    Sl+  02:31   0:00 /usr/bin/notify-send -a needrestart -u critical -i dialog-warning Relogin or restarts required! Your session is running obsolete binaries or libraries as listed below. <i><b>Please consider a relogin or restart of the affected processes!</b></i>\ncinnamon-sessio[18987]
]]]

This does not seem to have been reported yet: while #826044[1] and
#1002732[2] also concern hangs, my ps(1) output is different to theirs.

The issue went away once I edited /etc/needrestart/notify.d/400-notify-send
to export DBUS_SESSION_BUS_ADDRESS, as in the attached patch.  With that
patch, installs complete without delays and the notify-send(1) notification
does show up at the corner of the screen.

Thanks for maintaining the needrestart package,

Daniel

[1] #826044 - needrestart: Hangs in apt hook with a zombie

[2] #1002732 - needrestart stalled in background when performing update
with KDE Discover

P.S.  The patch is against the latest version in debsnap(1), 3.11-1, as
debcheckout(1) errored out.

#1141530#12
Date:
2026-07-05 21:42:02 UTC
From:
To:
Fixing metadata.  Sorry for the noise.

Daniel

#1141530#21
Date:
2026-07-10 03:46:32 UTC
From:
To:
Daniel Shahaf wrote on Sun, 05 Jul 2026 20:12 +00:00:
"needrestart: notify-send timeout instead of notify".  However, that bug
was fixed by s/su/runuser/ (via Michał's patch on #1024426), whereas
this bug occurs with a version of 400-notify-send that uses runuser(8).
So, please do consider the patch I posted here, and/or the similar patch
Roland had posted to #1024426 before me.

To be clear, I think there are two similar, but separate issues here:
one which was fixed by s/su/runuser/, as in Michał's patch, and one
that's fixable by exporting DBUS_SESSION_BUS_ADDRESS, as in Roland's and
my patches.

Thanks,

Daniel