Intercepting shutdown messges
José Alburquerque
jaalburquerque@cox.net
Fri Aug 15 01:39:00 GMT 2008
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
More information about the Libc-help
mailing list