strange little UNIX question....
Farooq Butt
fmbutt at mrbt.sw.stratus.com
Sat Dec 1 17:09:01 AEST 1990
Folks:
I've got a strange little UNIX question for you.
The problem:
I open an fd in a child process. The child process listens to the
user's keyboard and given a certain key ("%") issues a SIGUSR1 to its
parent that is listening on some other /dev/ttyfoo port. The parent
has a signal handler that traps SIGUSR1. The handler was devised to
restore the state of stdin (which I had previously converted to "raw"
so that every key I hit would immediately be read) and to exit. Now
here's the weirdness: if I issue a signal and exit from my child
process (the child changed stdin to raw mode) _and_ ioctl stdin from
the signal handler called by the _parent_ (i.e child screws with stdin
and makes it raw, child gets a key, child signals parent and quits
leaving handler to restore sanity) then the program causes a weird
error with telnet (I/O error on /dev/ttyp1) and generally blows my
session away. Now if I get the _child_ to restore stdin to sane
values before exiting (i.e. clean up its own mess) everything works
hunky dory.
What's up?
Isn't stdin stdin everywhere ? Why does re-ioctl'ing stdin back to
sane modes cause life to be weird if I do it from the signal handler?
Is there a relation to processes that I am missing ? If fd's are
indeed process-specific then how come some programs trash stdin
for the shell (many's the time I've had to do an stty after an
ill-behaved program)?
-fmb
--
Hi-Tech Disclaimer: NOTHING in the above article has any relationship
to reality. If any reality correspondences are found,
please notify me IMMEDIATELY. Any threats or abuse
of any kind is purely unintentional. My employer is not liable.
More information about the Comp.unix.internals
mailing list