Signal out from fork()'d shell script back to the C++ application

Hi,
I am writing a C++ application; in which at one point I fork() a new process, which executes a shell script (via execv() call).
Now the shell script can take a while to finish (tarring, burning a cd, etc.) and I would like to update the parent application about the progress (while the script is running).
Any ideas on how to do this?
Thank you!
Miro

The parent application can set up standard output of the shell script to be the write end of a pipe that the parent can use to read status from the child.

The parent can create a named pipe (or regular file) and pass the name of that file to the shell script as an operand. The child can then write status to that file and the parent can read status from that file.

The parent can set up a signal catching function for a signal and pass its process ID to the child shell script. The child can then use:

kill -signal_name parent_process_ID

to notify the parent that some milestone has been reached.

Use your imagination... There are lots of ways for one process to talk to another process.

1 Like

On a whole lot less imaginative vector:

6 Linux Interprocess Communications

There are umpteen different IPC mechanisms. -- basically: semaphores, mutexes, msg queues, locks, signals, shared memory, plain files, pipes. And lots of variants.

1 Like

Fantastic!
Thank you guys for pointing me in the right direction!