HomeClusterLabs Projects

Fix: tools: make crm_mon exit upon loss of the attached pseudo-terminal

Description

Fix: tools: make crm_mon exit upon loss of the attached pseudo-terminal

Previously when crm_mon was running in console mode, if the attached
pseudo-terminal got lost, crm_mon would persist in the background and
raise the CPU usage to 100%.

The situation triggers if use_pty is enabled for sudo, in which case
it creates a separate pseudo-terminal device for its child process.

A producer:

  • Enable use_pty by adding Defaults use_pty to /etc/sudoers
  • Open a console and execute: > sudo su -
    1. crm_mon
  • Open another console, find the PID of crm_mon's bash parent and kill it:
    1. kill -9 $(ps -C crm_mon -o ppid=)

The pty device created by sudo from the first console is basically
deleted, but crm_mon continues running in the background and raises the
CPU usage.

This commit fixes it by watching more conditions from stdin and exiting upon
(G_IO_ERR | G_IO_HUP).

The similar was reported and fixed for the more command:
https://github.com/util-linux/util-linux/pull/2635
https://github.com/util-linux/util-linux/pull/2795

The tail command is also impacted but hasn't been fixed so far.

There's the relevant discussion here:
https://github.com/sudo-project/sudo/issues/367

Fixes T16

Details

Provenance
gao-yanAuthored on Apr 22 2024, 12:49 PM
Parents
rP92cd6f742c3a: Merge pull request #3426 from clumens/schema-autoconf
Branches
Unknown
Tags
Unknown