liske / needrestart

Restart daemons after library updates.
GNU General Public License v2.0
426 stars 67 forks source link

breaks if output of stderr is redirected #294

Closed bahbarnett closed 2 months ago

bahbarnett commented 10 months ago

If I run:

# output=`needrestart -q -r l -f text `;echo "$?" ; echo "A: $output"
0
A: Pending kernel upgrade
----------------------

Newer kernel available

The currently running kernel version is 6.1.0-13-amd64 which is not the expected kernel version 6.1.0-15-amd64.

Restarting the system to load the new kernel will not be handled automatically, so you should consider rebooting.

All is fine. If I run:

# output=`needrestart -q -r l -f text 2>&1 `;echo "$?" ; echo "A: $output"
0
A:

all output vanishes.

The above worked fine on 3,.4, yet borks on 3.6.

liske commented 6 months ago

Running needrestart with stdin, stdout nor stderr being a terminal switches the user interface to stdio:

https://github.com/liske/needrestart/blob/2f077c714085a8eb45396da1951b28da181ce277/needrestart#L50

I cannot yet understand what could cause this issue.

liske commented 2 months ago

It looks like that this might be triggered by debconf. I was not able to reproduce it when needrestart does not use debconf:

# output=`needrestart -q -r l -u NeedRestart::UI::stdio`; echo "$?" ; echo "A: $output"
0
A:  systemctl restart fwupd.service
 systemctl restart mosquitto.service
 systemctl restart ssh.service
 systemctl restart systemd-journald.service
 systemctl restart systemd-machined.service
 /etc/needrestart/restart.d/systemd-manager
 systemctl restart systemd-udevd.service
 systemctl restart udisks2.service
 systemctl restart NetworkManager.service
 systemctl restart systemd-logind.service

Does this work for you?

liske commented 2 months ago

I'm closing this issue for now, feel free to reopen it if the problem still exists with the changed UI package.