fg,bg functionality
am 06.11.2007 19:51:29 von PayelHi,
I wrote a shell and want to add bg and fg functionality into it,
so I need guidance about how to write those functions.
Hi,
I wrote a shell and want to add bg and fg functionality into it,
so I need guidance about how to write those functions.
Payel
> I wrote a shell and want to add bg and fg functionality into it,
> so I need guidance about how to write those functions.
Not so much a "function or two" as more like a _framework_. Job
control is a non-trivial addition to a shell's functionality:
"Wikipedia: Job Control": overview
http://en.wikipedia.org/wiki/Job_control
The canonical whitepaper for modern job control is/was:
"A System V Compatible Implementation of 4.2BSD Job Control" by David
C. Lennert
http://www.weycrest.co.uk/information/infosec/info/admin/4.2 bsd_unix_job_control.pdf
A simpler and newer overview is:
"FreeBSD Process Management: 4.8 Process Groups and Sessions":
http://www.informit.com/articles/article.aspx?p=366888&seqNu m=8&rl=1
I cannot believe that there is not a POSIX standard for
job control, but all I could find was a standard for JC
UI behavior. Perhaps someone has more information.
For example code of (BSD?) job control incrementally added
to a simple shell, I recommend:
"ush.c": "Ultra Simple Shell" from Ch7 of book "Practical Unix
Programming"
http://vip.cs.utsa.edu/concurrency/programs.html
Robbins, Kay A. & Steven Robbins. "Practical UNIX Programming".
It is my emphatic suggestion that you instead utilize utilize
a pre-written (and pre-debugged!) job control framework, like:
http://www.gnu.org/software/libc/manual/html_node/Job-Contro l.html
BTW, long ago I was reasonable successful implementing remedial
but workable ksh-like job control emulation for ordinary Bourne
shell by writing trap handlers for the usual signals SIGTSTP/
SIGSTOP, SIGCONT (IIRC, SIGTTIN and SIGTTOU are not trappable),
and some _very_ fancy redirection. Sorry: not available anymore.
Good luck! -- you'll need it! ;)
=Brian
bsh wrote:
> but workable ksh-like job control emulation for ordinary Bourne
> shell by writing trap handlers for the usual signals SIGTSTP/
> SIGSTOP, SIGCONT (IIRC, SIGTTIN and SIGTTOU are not trappable),
It's actually KILL and - often overlooked - STOP.
Well, and CONT...
> and some _very_ fancy redirection. Sorry: not available anymore.
Sparc2? Is it your disk or your chassis that died?
If the disk is alive, what about trying to mount it on
something different which understands UFS, e.g. Linux?
In article <1194375089.327283.172680@22g2000hsm.googlegroups.com>,
Payel
> Hi,
>
> I wrote a shell and want to add bg and fg functionality into it,
> so I need guidance about how to write those functions.
Didn't you just ask the same question an hour earlier in the thread
"background and foreground process"?
Are you actively trying to get everyone to killfile you?
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Sven Mascheck
> bsh wrote:
> > but workable ksh-like job control emulation for ordinary Bourne
> > shell by writing trap handlers for the usual signals SIGTSTP/
> > SIGSTOP, SIGCONT (IIRC, SIGTTIN and SIGTTOU are not trappable),
>
> It's actually KILL and - often overlooked - STOP.
> Well, and CONT...
I can't put one over you, Sven! (I was writing in "Unix API
programmer mode", since that was the context of the OQ).
> > and some _very_ fancy redirection. Sorry: not available anymore.
> Sparc2? Is it your disk or your chassis that died?
> If the disk is alive, what about trying to mount it on
> something different which understands UFS, e.g. Linux?
SparcStation 1+ (Sun-4/65, Sun4c architecture, Maxtor HDD)
.... SCSI bus, or it could be a configuration issue -- SSs are very
unhappy when they are not connected to a network, and I've had
to make modifications to rc scripts. I have a QIC backup but have
had no success as of yet configuring my PC with an Adaptec
card -- which, BTW, is also currently moribund :( Every
computer I touch, breaks. Do not allow me anywhere near an
unbacked-up project!
I tried to mount the HDD on [both of my] SS2s and my SS5
Voyager (yes, I actually have one!). No luck. Heck, I cannot
even get an external _CDROM_ without beaucoup $$! It's
theoretically possible to mount Sun FSs under Linux, but
hardware issues still have to be surmounted.
I've tried network install, (heck, I've even built terminated RG-58
coax cabling necessary for the Sun adaptor card that I had!),
TFTP boot, everything! But really, the impediment is time and
money... Zdenek Sekera knows my plight -- I've had to rebuff
him for some time now because other pressing issues keep
the WSs (and some really cool scripts) in the closet.
That's why I keep annotating my submissions "not tested": no
command prompt, although I've been recently experimenting
with U/WIN.
=Brian