Interesting problem. The first question I have is why ?
Besides that question, you only have a couple of things to go by;
1) All commands (programs) that are "run" from a shell script will be shell processes.
(Unless you do something nutty like starting it with "WBRun" or other tricks.)
2) The commands parent PID number will be the same as the "Initial CLI" process PID.
(See also; GetPID() and ProcessScan() autodocs.)
That's about all you have that keeps launch method and the parentage info intact.
Checkout the "Ranger" tool, it gives you some valuable insight into process struct fields.
If you just want to check if your program was started from CLI or WB you can do so by checking the argc parameter passed to main() (== 0 for WB startup and > 0 for CLI startup).
For more details see the "Startup Code" section on the AmigaOS wiki:
https://wiki.amigaos.net/wiki/Newlib_Library#Startup_Code
It is not a matter of starting either from WB or from CLI. It is a matter of starting from a very particular file (so CLI), i.e. SYS:S/User-Startup.
It seems pretty hard to obtain that info. So far I've gotten that the process's ParentID is 0, where I more or less expected it to be the ProcessID of SYS:S/Startup-Sequence. No such luck, however.
Unless "run" is used to execute the command asynchronously, it will be executed directly on the same process context as the script so instead of looking at GPID_PARENT you should be looking at GPID_PROCESS.
Ok, as salass00 said, it depends on whether it is "run" or not.
For example, if the program itself is "run" from the U-S, it will have a
ParentID the same as the "Initial Cli" process, which in my case was
process 6, the same as "ramlib" ParentID, which was started from it
as well.
If the program itself is not "run" from the U-S, but executing from the
"Initial Cli" process context, it will have the same values as that process,
which in my case was ProcessID 6 again, but the ParentID will be 0,
as the "Initial Cli" was started from an exec task as the first DOS process.
Interesting problem. The first question I have is why ?
Besides that question, you only have a couple of things to go by;
1) All commands (programs) that are "run" from a shell script will be shell processes.
(Unless you do something nutty like starting it with "WBRun" or other tricks.)
2) The commands parent PID number will be the same as the "Initial CLI" process PID.
(See also; GetPID() and ProcessScan() autodocs.)
That's about all you have that keeps launch method and the parentage info intact.
Checkout the "Ranger" tool, it gives you some valuable insight into process struct fields.
Hi,
Thanks for your clear answer. I think I can now add at least one more step in solving the puzzle.
OldFart
If you just want to check if your program was started from CLI or WB you can do so by checking the argc parameter passed to main() (== 0 for WB startup and > 0 for CLI startup).
For more details see the "Startup Code" section on the AmigaOS wiki:
https://wiki.amigaos.net/wiki/Newlib_Library#Startup_Code
@Salass00:
It is not a matter of starting either from WB or from CLI. It is a matter of starting from a very particular file (so CLI), i.e. SYS:S/User-Startup.
It seems pretty hard to obtain that info. So far I've gotten that the process's ParentID is 0, where I more or less expected it to be the ProcessID of SYS:S/Startup-Sequence. No such luck, however.
Thanks anyway,
OldFart
Unless "run" is used to execute the command asynchronously, it will be executed directly on the same process context as the script so instead of looking at GPID_PARENT you should be looking at GPID_PROCESS.
Ok, as salass00 said, it depends on whether it is "run" or not.
For example, if the program itself is "run" from the U-S, it will have a
ParentID the same as the "Initial Cli" process, which in my case was
process 6, the same as "ramlib" ParentID, which was started from it
as well.
If the program itself is not "run" from the U-S, but executing from the
"Initial Cli" process context, it will have the same values as that process,
which in my case was ProcessID 6 again, but the ParentID will be 0,
as the "Initial Cli" was started from an exec task as the first DOS process.
Hope that explains it adequately.