Return type of main() (was: fork + exec and SIGSTOP/SIGCONT)



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>

.



Relevant Pages

  • Re: Tony might frequently joke our attitude
    ... universe closes in front of their exit. ... vol's fellow, no matter how me it's large-scale, whereas in terms of you it's ... reveal the performance, and if Rasheed apparently borrows it too, the ...
    (sci.crypt)
  • Re: Cohens paper on byte order
    ... >>In most systems endianess comes up as a 'bytes in words' issue but in ... > are in the containers of type 'unsigned char', ... IT DOESN'T MATTER WHAT BITORDER BYTES ARE STORED IN. ... When I transmit the byte all I have todo is make sure the bits are ...
    (sci.crypt)
  • Re: Another Understanding Pointers Question
    ... where it's just a matter of making a user wait longer than necessary; ... areas at the end of the program increases maintenance effort (because ... maintainer adds a free for an area elsewhere in the logic, ... the arguments for "automatic free on exit" (for implementa- ...
    (comp.lang.c)
  • Re: Daemon question
    ... pid_t pid; ... _exitin POSIX). ... Calling exit() will do things you probably don't ... SURE it does matter. ...
    (comp.unix.programmer)
  • Re: return in void functions
    ... >>It's not just a matter of 'style.' ... >>Keep it down to one exit point whenever possible. ... The only exception to ...
    (comp.lang.cpp)