return and exit from main: difference

Basically the difference between following programs !

//ret.c
int main()
{
return 43;
}
//exit.c
int main()
{
exit(43);
}

well, there are three ways for the processes to exit: -

1. Voluntary exit (implicit)
2. Voluntary exit (explicit)
3. Involunatary exit

Voluntary exit can be implicit e.g. in case of return and explicit e.g.
in case of a call to exit(). Involuntary exit is like being killed by a
third process, receiving a SIGSTP signal (or other signals whose default ot set
behavior results in terminating the process).


See also