A shell script is not a process by itself. It is interpreted by an instance of the shell, which is the process.
. is an alias of the
source command that executes commands in the current shell environment. This means
./foo.sh is executed by the same shell that executes the script that launches it. It does not create a new process and this is why you cannot find it using
You can launch
./foo.sh. In this case it will be executed by a new instance of the shell, i.e. into a new process.
But, depending on what it does, the execution of the original shell after
./foo.sh completes might be different in the two cases. When
foo.sh is executed in the same shell, the environment variables it changes belong to the shell that also executes the original script. Changing them could affect the original script.
When you run
foo.sh in a separate script the changes it operates on the environment variable do not affect the original script. They are different processes, the do not share anything.
but how can I check if
foo.sh is running at all?
This is easy from the script that launched
foo.sh because it waits until
foo.sh completes before resuming its execution.
It is probably impossible (or almost there) from outside.