Return type of main() (was: fork + exec and SIGSTOP/SIGCONT)
- From: Geoff Clare <geoff@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 24 May 2012 13:13:07 +0100
Scott Lurndal wrote:
Joshua Maurice <joshuamaurice@xxxxxxxxx> writes:
On May 22, 12:56=A0pm, sc...@xxxxxxxxxxxxx (Scott Lurndal) wrote:
Joshua Maurice <joshuamaur...@xxxxxxxxx> writes:
On May 22, 11:54=3DA0am, dmarkh <dma...@xxxxxxxxxx> wrote:
[...]
int32_t main(int argc, char **argv)
Minor pedantic point. The return value of main should be "int", not
"int32_t".
however, since only the lower 8-bits of the return value are made
available via wait(2)/waitpid(2)/waitid(2), it really doesn't matter
how it is declared.
I'd be hesitant to conclude this. Big-endian and little-endian, just
for starters.
Endianess doesn't matter in this case. The WEXITSTATUS() macro will
return the least significant 8 bits, regardless of the endianess of
a machine word.
That's not where the problem would arise, if it does. The program
start-up code calls main() and expects it to return an int. It will
use the value it gets back from main() to set the process's exit status.
If main() has been defined with a different type, the code that called
it might get the wrong value, and use that wrong value to set the
exit status.
--
Geoff Clare <netnews@xxxxxxxxxxxxx>
.
- References:
- fork + exec and SIGSTOP/SIGCONT
- From: dmarkh
- Re: fork + exec and SIGSTOP/SIGCONT
- From: Joshua Maurice
- Re: fork + exec and SIGSTOP/SIGCONT
- From: Scott Lurndal
- Re: fork + exec and SIGSTOP/SIGCONT
- From: Joshua Maurice
- Re: fork + exec and SIGSTOP/SIGCONT
- From: Scott Lurndal
- fork + exec and SIGSTOP/SIGCONT
- Prev by Date: Re: Compilation under HPUX or any other commercial Unix
- Next by Date: Re: Compilation under HPUX or any other commercial Unix
- Previous by thread: Re: fork + exec and SIGSTOP/SIGCONT
- Next by thread: Re: fork + exec and SIGSTOP/SIGCONT
- Index(es):
Relevant Pages
|