I'm wondering if there is a way to start a child process (not as a background process), and get its PID, possibly outputting it to a file.
I am starting a process in a bash script, namely java, and I'd like to be able to output the PID of this java process to a file, so I can use it in other scripts. The problem is that I'm not starting java as a background process, so I can't use
$!. Any ideas onto how I would output the PID of the
java process that I just started to a file?
Note that this java process is not going to be the only java process running on the system - if I get this working I'll be outputting the child process for different java processes to different files.
Only thing I've thought of is possible starting a background process that knows the PID of the current bash script, before starting java. Then using that background process to find the child process from the bash script. I wouldn't know exactly how to implement this though.