in reply to getting the return value from a C program
The return value of main() in a standalone C program is used as an error or status indication code and should not be used for other purposes. Normally programs should return 0. Its range is also limited: 0-255 (?) integer on most (UNIX) systems.
If that's what you really want (I doubt), here's how you can get to it (tested on Linux) (see perldoc perlvar for documentation on $?)
$ cd /tmp $ cat > ret5.c int main(int argc, char **argv) { return 5; } ^D $ gcc ret5.c -o ret5 $ perl system './ret5'; printf "child return code is: %d\n", $? >> 8; ^D child return code is: 5 $
|
|---|