[cs631apue] exit() vs return in c programs

Liang Luo lluo1 at stevens.edu
Wed Sep 10 16:01:11 EDT 2014


In Man page,
[image: Inline image 1]
[image: Inline image 2]

You can use both if you simply want to terminate program. However, only
exit(int status) will give feed back to the parent parent process.
See fork() or google pthread if you are interest in it.

On Wed, Sep 10, 2014 at 3:32 PM, Sadia Akhter <sakhter at stevens.edu> wrote:

> Hi,
>
> In my previous experience with C, I have always used "return 0;" to return
> from main() function. Those were of course not any system programming
> codes. However, in the text book APUE, I noticed that they always use
> "exit(0)" in main(). Can anyone tell me why is that? Is there any
> significant difference between these two? Or is it just regular practice?
>
> Thanks,
> Sadia Akhter
> _______________________________________________
> cs631apue mailing list
> cs631apue at lists.stevens.edu
> https://lists.stevens.edu/mailman/listinfo/cs631apue
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.stevens.edu/pipermail/cs631apue/attachments/20140910/ddf9d4b4/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 6621 bytes
Desc: not available
URL: <http://lists.stevens.edu/pipermail/cs631apue/attachments/20140910/ddf9d4b4/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 8270 bytes
Desc: not available
URL: <http://lists.stevens.edu/pipermail/cs631apue/attachments/20140910/ddf9d4b4/attachment-0003.png>


More information about the cs631apue mailing list