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

Re: Does anyone understand terminal job control?



On Sun, Feb 08, 2009 at 05:52:34PM +1000, Adrian Levi wrote:
> 2009/2/8 Daniel Burrows <dburrows@debian.org>:
> >  Hello list,
> >
> >  I've been banging my head on this one for a while.
> >
> >  I have a need to write some code that can manage job control on a
> > terminal.  More specifically, I need to run a single process and stuff
> > it into the background at will, so that it gets suspended when it tries
> > to read from the terminal.  So, there's a "controller" process and
> > a "subprocess" process.
> >
> >     controller  ----------> subprocess
> >                   manages

Is the single process a black box or are you writing it too?  If its not
a black box, can't its reads from the terminal just sit and wait for
input (or test a semiphor before doing anything with the terminal)?

If it is a black box, what happens if it tries to read from std-in if
std-in doesn't have anything?  Perhaps your controller program will have
to be a filter between the process and the terminal: pipe its std-in an
std-out to the controller process and the controller process issue the
appropriate shell start/stop commands as necessary while leaving the
process in the background the whole time.  If this model works, then
this controller process can manage any number of daughter processes,
each using e.g. a pair of named pipes for std-in and std-out.

Just an early-morning thought.

Doug.


Reply to: