The return from main() is handed to exit(). From "man 3 exit" (macOSX,
but other UNIX are essentially the same):
[...]
void exit(int status);
[...]
make the low-order eight bits of the status argu- ment available
to a parent process which has called a wait(2)-family function.
You don't get the unadorned "return" value. The exit status of a program
is small integer with some signal information folded in. It is essentially
meant for program control flow ("did the program succeed or fail, was it
killed by a signal").
If you want to return arbitrary information from a program, print it to
the standard output or so a file.
Cheers,
--
Cameron Simpson <c...@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/
Think of it as evolution in action. - Tony Rand, _Oath of Fealty_
Yes.
| So, if the queue depth is larger than 256 ... I will loose the higher
| bits ?
Larger that 255 will do it.
The program exit status is more about success/failure logic than the
program result. The program result typically goes to the standard
output.
Typical example:
if grep foo some-file >grep.out
then
echo 'lines containing "foo" are in the file "grep.out"'
else
echo 'no lines contained "foo"'
fi
The program (grep) result went to the file "grep.out".
The program exit status is zero (success) if some lines were found
and non-zero (usually the value 1) if no lines were found.
So grep has a "return 0" if it finds lines and "return 1" if not.
The other nonzero values you can use with return (or the exit()
function) can be used if you want to distinguish different failure
modes. Personally I usually use 1 for "normal" failure and 2 for "bad
invocation" such as using invalid command line options.
Various other programs may have a small suite of non-zero values for
particular error conditions.
Cheers,
--
Cameron Simpson <c...@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/
Ode to a Squid:
Half a mile, half a mile,
Half a mile onward,
All in the Valley of Death
Rode the Six Hundred.
Copyright Tennyson/Richards(tm)
- Jan Richards <Jan_Ri...@dge.ceo.dg.com>
I put 261 messages in the queue = 256 + 5 ... and the "myrc=$?" value
is "5" ....
Cheers, man !
+++
Sample INQQD end - RC [261]. <<<<<<<<<<<<<< real queue
depth, before "return()"
MyRC is 5 <<<<<<<<<<<<<<
value captured in $?
+++
On 16 Nov, 23:02, Cameron Simpson <c...@zip.com.au> wrote:
> Cameron Simpson <c...@zip.com.au> DoD#743http://www.cskk.ezoshosting.com/cs/
>
> Ode to a Squid:
> Half a mile, half a mile,
> Half a mile onward,
> All in the Valley of Death
> Rode the Six Hundred.
> Copyright Tennyson/Richards(tm)
> - Jan Richards <Jan_Richa...@dge.ceo.dg.com>