Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NeedRestart::UI assumes STDOUT is a terminal, fails to run when piped #86

Closed
guillaume-uH57J9 opened this issue Nov 1, 2017 · 3 comments
Assignees
Labels
Milestone

Comments

@guillaume-uH57J9
Copy link
Contributor

I encounter issues running needrestart in an unattended manner because NeedRestart::UI assumes STDOUT is a terminal.

This bug was previously logged downstream as Debian bug #859387. I am logging this here as I believe the issue is upstream.

The following command:
DEBIAN_FRONTEND=noninteractive needrestart -q -r l | logger -s

Gives the following error:
Unable to get Terminal Size. The TIOCGWINSZ ioctl didn't work. The COLUMNS and LINES environment variables didn't work. The resize program didn't work. The stty program didn't work. at /usr/share/perl5/NeedRestart/UI.pm line 50.

Explanation of the command:

  • Variable DEBIAN_FRONTEND=noninteractive tells debconf not to wait for user interaction regarding kernel updates. This is a workaround for List-only mode should not require interaction for kernel updates #67
  • Command logger -s sends the output to syslog and STDERR. The actual command is not important, the catch here is NeedRestart::UI doesn't expect the output to be piped to another process, it expect instead STDOUT to be a terminal.
@guillaume-uH57J9 guillaume-uH57J9 changed the title NeedRestart::UI assumes STDOUT is a terminal, fails to run from script NeedRestart::UI assumes STDOUT is a terminal, fails to run when piped Nov 1, 2017
@guillaume-uH57J9
Copy link
Contributor Author

guillaume-uH57J9 commented Nov 1, 2017

As an alternative I've tried using the batch mode as follows, which works without a terminal:
needrestart -q -b

But it appears to ignore the quiet option and always prints needrestart's version, which is not desired.

So still no solution in sight.

@guillaume-uH57J9
Copy link
Contributor Author

I submitted a pull request along with an example command to run needrestart in a unattended manner, and produce a human-readable output:

needrestart -u NeedRestart::UI::stdio -q -r l | logger -s

@liske liske self-assigned this Nov 1, 2017
@liske liske added the bug label Nov 1, 2017
@liske liske added this to the v2.12 milestone Nov 1, 2017
@liske liske closed this as completed in 4e13810 Nov 1, 2017
@liske
Copy link
Owner

liske commented Nov 1, 2017

Hi,

the batch options does indeed ignore the quiet option intentional. The batch option prints all findings in a parsable format (used by DE-IBH/apt-dater) for further processing so the quiet option does not make any sense. I'm considering to add another option to needrestart to enforce a unattended/non-interactive mode.

HTH,
Thomas

mscherer added a commit to mscherer/needrestart that referenced this issue Apr 6, 2018
Followup of the bug fix in liske#86, triggered by running needrestart
with yum/dnf in cron
mscherer added a commit to mscherer/needrestart that referenced this issue Apr 6, 2018
Followup of the bug fix in liske#86, triggered by running needrestart
with yum/dnf in cron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants