🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #11856

Re: background jobs

#11856
From: Werner Guenther
Date: Thu, 16 Mar 1989 18:38
35 lines
1921 bytes
[....]

In article <1243@hudson.acc.virginia.edu> Pete Yadlowsky <pmy@vivaldi.acc.v
irginia.edu> writes:
>Can someone show me a way to make a program detach itself from the
>CLI from which it was invoked? That is, I'd like to have a particular
>program put itself in the background if it was not explicitly 'run'.


The code to detach from your CLI process is quite simple. If you are using
a C compiler, just use one of their detaching startup files, both Lattice and
Manx did put them into their libraries.
 If you are writing a program in assembler, this is the general way to go:

Programs are loaded by the scatter loader into different hunks (sections,
segments, whatever). These segmets are linked together by a so called
segment list. Each entry starts with two longwords containing:
the length of this hunk (in longwords),
a pointer to the next hunk (BCPL).

What you have to do now, is to split your program into (at least) two
hunks: the first one containing your detach routine, the second one your
main program.
The detach routine has to read the pointer to the next hunk (the main program)
and starts the second hunk as a process (using CreateProc()). Then zero
the pointer to the next hunk (still the main program), and exit (rts or
Exit()).
 The only change you have to do in the main program, is that it has to
UnLoad() itself before exiting.

I don't have any manuals here at work, so I won't add a sample listing,
but I promise to send a short one tomorrow.
Hope it helps,
Werner
Technical Details
Message-ID: <8903161837.AA02387@jade.berkeley.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!DHDURZ1.BITNET!G35

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!DHDURZ1.BITNET!G35
From: G35@DHDURZ1.BITNET (Werner Guenther)
Newsgroups: comp.sys.amiga.tech
Subject: Re: background jobs
Message-ID: <8903161837.AA02387@jade.berkeley.edu>
Date: 16 Mar 89 18:38:32 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Lines: 35
X-Unparsable-Date: Thu, 16 Mar 89 19:26:05 CET