Skip to content

โ† Home ยท AmigaDOS

Process Management โ€” CreateNewProc, SystemTagList, Execute

Overview

AmigaDOS provides several ways to launch child processes, ranging from the low-level CreateNewProc to the shell-level Execute and SystemTagList.


CreateNewProcTags (OS 2.0+)

/* dos/dostags.h โ€” NDK39 */
struct Process *proc = CreateNewProcTags(
    NP_Entry,       myFunction,     /* function pointer */
    NP_Name,        "Worker",       /* task name */
    NP_StackSize,   8192,           /* stack size in bytes */
    NP_Priority,    0,              /* scheduling priority */
    NP_Input,       Open("NIL:", MODE_OLDFILE),
    NP_Output,      Open("NIL:", MODE_NEWFILE),
    NP_CloseInput,  TRUE,           /* close input on exit */
    NP_CloseOutput, TRUE,
    NP_CurrentDir,  DupLock(currentDir),
    TAG_DONE);

Tag Constants

Tag Value Meaning
NP_Entry โ€” Function to run as the new process
NP_Seglist โ€” Alternative: run from a loaded segment list
NP_Name โ€” Process name (appears in task list)
NP_StackSize โ€” Stack size in bytes (default 4096)
NP_Priority โ€” Task priority (โˆ’128 to +127)
NP_Input โ€” BPTR stdin handle
NP_Output โ€” BPTR stdout handle
NP_Error โ€” BPTR stderr handle (OS 3.0+)
NP_CurrentDir โ€” Lock for current directory
NP_HomeDir โ€” Lock for PROGDIR:
NP_CopyVars โ€” Copy parent's local vars to child

SystemTagList โ€” Run a Shell Command

/* Execute a command string as if typed in a shell: */
LONG rc = SystemTagList("dir SYS: ALL", NULL);
/* rc = return code from the command */

/* With custom I/O: */
LONG rc = SystemTagList("list RAM:", (struct TagItem[]){
    { SYS_Input,  Open("NIL:", MODE_OLDFILE) },
    { SYS_Output, Open("RAM:output.txt", MODE_NEWFILE) },
    { TAG_DONE, 0 }
});

Execute โ€” Legacy Command Execution

/* dos.library LVO โˆ’132 */
BOOL Execute(STRPTR command, BPTR input, BPTR output);
  • command โ€” shell command string
  • input โ€” BPTR to additional input (0 = none)
  • output โ€” BPTR to output handle (0 = current)

WaitForChild / Process Exit

Child processes are independent tasks. To synchronize: 1. Use a shared MsgPort โ€” child sends a death message 2. Check pr_Result2 after the child task exits 3. Use SYS_Asynch tag with SystemTagList for fire-and-forget


References

  • NDK39: dos/dostags.h, dos/dosextens.h
  • ADCD 2.1: CreateNewProc, SystemTagList, Execute
  • tasks_processes.md โ€” Task/Process structures