[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finding the last foreground command in the current session

From: Debarshi Ray
Subject: Re: Finding the last foreground command in the current session
Date: Tue, 9 Jun 2015 19:44:44 +0000
User-agent: Mutt/1.5.23 (2014-03-12)

Hey Stephane,

On Fri, May 22, 2015 at 02:38:31PM +0100, Stephane Chazelas wrote:
> Can you not just do a tcgetpgrp() periodically

If by "periodically" you mean "polling", then no, I don't want to do
that.  I know a few terminal emulators do that, but it is bad for
power consumption and battery life.

(We already use tcgetpgrp for checking if there is a foreground
process when the user clicks the 'x' buton.)

> (or upon tty
> setting change since modern shells change the tty settings
> when entering and leaving their prompt) on the pseudo-tty
> (doing it on the master side seems to work as well at least on
> Linux) and use the names of the processes in that group (from
> /proc for instance)?

I didn't know that. I did try putting an inotify watch on the slave
pseudo-terminal device, but it did not pick up any events.

inotify(7) says:
"Furthermore, various virtual filesystems such as /proc, /sys, and
/dev/pts are not monitorable with inotify."

Or is there any other way to detec this?


Attachment: pgpY9H8aMEn1j.pgp
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]