🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: background jobs

#11869
From: Werner Guenther
Date: Fri, 17 Mar 1989 15:02
94 lines
3260 bytes

In article <8903161837.AA02387@jade.berkeley.edu> Werner Guenther <G35@dhdurz1.b
itnet> writes:

>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'.

[....]

>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.

Here it is:

            XDEF    _SysBase
            XDEF    _DOSBase
            XDEF    _stdout

            XREF    _LVOOldOpenLibrary
            XREF    _LVOCreateProc
            XREF    _LVOForbid
            XREF    _LVOUnLoadSeg
            XREF    _LVOOutput
            XREF    _printf

AbsExecBase equ     4

start       CODE    FireUp

            lea     input,a1           ;commadline has to be copied
getparms    move.b  (a0)+,(a1)+
            dbf     d0,getparms

            move.l  AbsExecBase,a6
            move.l  a6,_SysBase

            lea     dosname,a1
            jsr     _LVOOldOpenLibrary(a6)
            move.l  d0,_DOSBase

            move.l  d0,a6
            jsr     _LVOOutput(a6)
            move.l  d0,_stdout
*
* This is the segment splitting routine
*
            lea     start(PC),a0        ;pointer to the first byte in our hunk
            move.l  -4(a0),d3           ;save BPTR to next hunk
            clr.l   -4(a0)              ;split segment
            move.l  d3,segptr           ;we need this one later
            move.l  #name,d1            ;Name
            move.l  #5,d2               ;Priority
            move.l  #2000,d4            ;Stack
            jsr     _LVOCreateProc(a6)  ;start our main program

            rts                         ;and exit to CLI


Main        CODE

            pea     input            ;print something
            move.l  segptr(PC),d1
            lsl.l   #2,d1
            move.l  d1,-(a7)
            pea     text(PC)
            jsr     _printf
            lea     12(a7),a7

            move.l  _SysBase(PC),a6
            jsr     _LVOForbid(a6)        ;better Forbid() or we may
            move.l  _DOSBase(PC),a6       ;get UnLoaded() before exiting
            move.l  segptr(PC),d1
            jsr     _LVOUnLoadSeg(a6)     ;UnLoad() own Task
quit        rts                                ;and exit

segptr      dc.l    0
_SysBase    dc.l    0
_DOSBase    dc.l    0
_stdout     dc.l    0
name        dc.b    'TestProc',0
dosname     dc.b    'dos.library',0
text        dc.b    'Task has been started at 0x%08lx '
            dc.b    'with these parameters:,10,'%s',0

            BSS
input       ds.b    256
            END

Later,
Werner
Technical Details
Message-ID: <8903171501.AA15361@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: <8903171501.AA15361@jade.berkeley.edu>
Date: 17 Mar 89 15:02:20 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Lines: 94
X-Unparsable-Date: Fri, 17 Mar 89 15:50:36 CET