Subject: Re: device driver causing fork & exec
To: None <ronald@demon.net>
From: Eric Fischer <eric@fudge.uchicago.edu>
List: tech-kern
Date: 11/14/1998 17:52:15
> From: Ronald Khoo <ronald@demon.net>
>
> > Is it safe for the read() routine of a device driver to cause the
> > process doing the reading to spontaneously fork and exec?  Is it
> > sane?  I'm trying to get back into user space somehow without
> > requiring the reading process to know that anything special needs
> > to be done.
> 
> In fact if this is uncommon, you only need one control device and
> associated process taking care of control stuff for a whole farm of
> main devices.
> 
> Any reason why a traditional approach like this wouldn't work for you?

I'm not sure whether it would work.  What I'm actually trying to
do is a new tty driver line discipline which, among other things,
needs to be able to trigger a "completion" routine when the user
types an appropriate character (ESC or TAB).  Programs that know
how to do their own completion can signify this by setting up
a signal handler which I can then trigger from inside the kernel,
but there also needs to be a default completion mechanism for
programs that don't want to do anything special.

The tricky part is that the completion routine needs to run with the
same working directory (and, ideally, the same uid and gid) as the
program that's reading the tty.  I suppose it's possible to make the
daemon do a spontaneous chdir() at the appropriate time (or somehow
get it a file descriptor that it can fchdir() to) but this doesn't
seem like a very nice way to behave either. 

eric