Thanks for this great information Colin, and I must say that the new AutoDoc for SystemTags() is very good.
There is just one problem! I got it working with SystemTags() and then I found this comment in my code:
/* Load the command executable into memory and use the returned segment list to create a new process */
/* with CreateNewProcTags(). We do it like this because this is the only way to capture the child's */
/* exit code. Using SystemTags() results in the shell's exit code being returned, not the child's */
Now I remember the history. I checked my git history, and for years until 2023 I used SystemTags(), but then a user asked for me to add the ability to return the return code of the program that was being launched. I couldn't figure out how to do this using SystemTags(), so that's why I switched to CreateNewProcTags(). Now I changed it back to SystemTags() and pass in NP_ExitCode and NP_ExitData (which the OS4 AutoDocs say you can do) but on OS3 when the NP_ExitCode function is called, it gets a crazy exit code value in d0. On OS4 it gets the correct value. This is with an m68k executable.
Is passing NP_ExitCode and NP_ExitData into SystemTags() only supported on OS4?
Crash when reading from a PIPE:
- colinw
- AmigaOS Core Developer
- Posts: 218
- Joined: Mon Aug 15, 2011 9:20 am
- Location: Brisbane, QLD. Australia.
Re: Crash when reading from a PIPE:
The NP_ExitCode and NP_ExitData are supported on both OS3 and OS4.
It's just that the 3rd argument(SysBase:A6) is not available for OS3,
I added that for OS4 in 53.38
The reason it works on OS4 is because I intentionally preserve the returncode
and result2 codes right up to the exitcode function vector in process cleanup()
mainly for the death notification. (See; NP_NotifyOnDeathMessage)
OS3 just had random garbage in register D0 by the time it got there.
However, that's not where your problem is...
You are assuming a process-centric operation, not a shell-handler centric operation,
The shell-handler doesn't pass that data around in the process structure,
the shell-handler returns command results in the attached CLI structure instead.
So, when the command execution finishes, pick up the cli command return code
information from the cli structure itself, the exitcode() vector is still called by
the same process context in both OS3 and OS4, the data should still be in there,
unless the shell intentionally cleared it. (I havn't checked that).
//===============================
struct CommandLineInterface *cli = IDOS->Cli();
int32 returncode = (cli) ? cli->cli_ReturnCode : 0;
int32 ioerrcode = (cli) ? cli->cli_Result2 : 0;
//===============================
It's just that the 3rd argument(SysBase:A6) is not available for OS3,
I added that for OS4 in 53.38
The reason it works on OS4 is because I intentionally preserve the returncode
and result2 codes right up to the exitcode function vector in process cleanup()
mainly for the death notification. (See; NP_NotifyOnDeathMessage)
OS3 just had random garbage in register D0 by the time it got there.
However, that's not where your problem is...
You are assuming a process-centric operation, not a shell-handler centric operation,
The shell-handler doesn't pass that data around in the process structure,
the shell-handler returns command results in the attached CLI structure instead.
So, when the command execution finishes, pick up the cli command return code
information from the cli structure itself, the exitcode() vector is still called by
the same process context in both OS3 and OS4, the data should still be in there,
unless the shell intentionally cleared it. (I havn't checked that).
//===============================
struct CommandLineInterface *cli = IDOS->Cli();
int32 returncode = (cli) ? cli->cli_ReturnCode : 0;
int32 ioerrcode = (cli) ? cli->cli_Result2 : 0;
//===============================
- colinw
- AmigaOS Core Developer
- Posts: 218
- Joined: Mon Aug 15, 2011 9:20 am
- Location: Brisbane, QLD. Australia.
Re: Crash when reading from a PIPE:
Just wanted to confirm that the CLI structure returncodes are still valid
by the time the process cleanup() code is called (ie; exitcode() location)
I opened up a shell, did a dir of a bad path, it failed, then closed the shell
and this is what was in the cli structure when the process was being deleted;
[DOS] DBG: (Shell Process) residual cli values; r1=10 r2=205
by the time the process cleanup() code is called (ie; exitcode() location)
I opened up a shell, did a dir of a bad path, it failed, then closed the shell
and this is what was in the cli structure when the process was being deleted;
[DOS] DBG: (Shell Process) residual cli values; r1=10 r2=205