On Sunday 26 January 2003 01:12 pm, exits funnel wrote: > Hello, > > I've written the following simple program: > > #include <cstdlib> > > int main( ) > { > // /fff does not exist > int return_value = system("ls -l /fff"); > cout << "\n Return Value: " << return_value << "\n"; > return return_value; > } > > When I compile this and run it from bash I see "Return > Value: 256" at stdout as I'd expect. However, I then > immediately 'echo $?' and bash spits back '0' rather > than '256.' Is this correct? Shouldn't $? hold the > return value of the last program run from bash (ie, my > c program?) Thanks in advance for any replies.
Your problem is that you need to call exit() and not return() from main() to set the exit value. -- DDDD David Kramer http://thekramers.net DK KD DKK D "Some men are born mediocre, some men achieve mediocrity, DK KD and some men have mediocrity thrust upon them." DDDD -Joseph Heller (1923-1999) "The Great Executive Dream" -- redhat-list mailing list unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe https://listman.redhat.com/mailman/listinfo/redhat-list