liske/needrestart

breaks if output of stderr is redirected

bahbarnett opened this issue · 3 comments

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.

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

my $is_tty = (-t *STDERR || -t *STDOUT || -t *STDIN);

I cannot yet understand what could cause this issue.

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?

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