Quote:
Originally Posted by
Straitsfan
My apologies -- but your explanation is fine. So I'm guessing that a subprocess consists of other executions required to carry out the primary executions of said instructions?
Now I'm the one scratching my head, no idea what you're saying here. Maybe first off we should explain what a process is.
A process is an independent virtual memory space that a program can execute inside. It has its own independent set of memory, set of open files, and its own program context.
You get a sub-process when this process makes the
fork() system call. It creates a near-perfect copy of the old process all the way down to open files and what instruction its currently running, with one significant difference: the 'child' process will have zero returned to it from the fork() call, while the 'parent' process will have the new process' PID returned to it. Based on that the same program can take different directions. Also, when the 'child' terminates, the 'parent' is told about it via a signal.
So, they're independent, but may share some things like files, and they know which created which.
The only process with no parent at all is process 1,
init. All other processes are created by fork(). So a child process isn't some special kind of process apart, it's just a description of which process created which.
Whenever you run a shell script it's probably running in a sub-process. the shell forks off a new process and runs the script inside it.