This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Intercepting shutdown messges
- From: José Alburquerque <jaalburquerque at cox dot net>
- To: libc-help at sourceware dot org
- Date: Thu, 14 Aug 2008 21:38:37 -0400
- Subject: Re: Intercepting shutdown messges
- References: <48A342A7.3030303@cox.net>
José Alburquerque wrote:
Hello. This is my first post to this list and I simply have a general
question about pseudo terminals which I'm hoping can be answered on
this list! As weird as it may sound, I'm trying to write a simple
program (in C naturally) to sort of "intercept" shutdown messages when
they are sent to terminals (I notice that all my open terminals
receive a "The system is going down in XXX minutes" when shutdown is
running). To this end, I wrote a simple program that uses opentty()
to open a master/slave pseudo terminal pair. I can read and print
data sent to the /dev/pts/* file sent to the slave using the master
file descriptor, but I'm sort of stuck because when shutdown runs, my
program doesn't read the shutdown messages. Anyone have any
suggestions as to what I need to add to "intercept" these shutdown
messages? Am I going about this the wrong way? Thanks for any help.
By researching and a bit of trial and error, I discovered that it is
necessary to use login() to append the utmp file so that the process
receives these system messages. Thanks.
--
José Alburquerque