views:

137

answers:

1

I want the process running to exec. When the command exec runs finishes, I want the process that called the process calling exec to recieve as a return value the value that the function called by exec returned. How is this possible?

I'm sorry. I understand the process is a bit confusing. So let me give an example I am in a bash script, call it b_scr.

In b_scr I call a program foo. In turn foo calls exec which executes bar. I wish b_scr to get as the return value of foo, the return value of bar.

So in b_scr:

# Call foo
foo
# print return value of foo.
echo $?

bar
# should be the same value as printed before.
echo $?

foo

... int main() { ...

 exec("bar",0);

}

+2  A: 
Eric Warmenhoven