From: rinku rathore <rinku_ques@yahoo.com>
To: Micha Feigin <michf@post.tau.ac.il>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: exit(42)
Date: Sat, 25 Sep 2004 03:57:36 -0700 (PDT) [thread overview]
Message-ID: <20040925105736.71615.qmail@web53005.mail.yahoo.com> (raw)
In-Reply-To: <20040925011323.GD3825@luna.mooo.com>
--- Micha Feigin <michf@post.tau.ac.il> wrote:
> On Fri, Sep 24, 2004 at 12:57:59PM +0100, Ankit Jain
> wrote:
> > well do any body know what does this mean?
> >
> > exit(42)
> >
>
> It means return value 42 as the exit value for the
> program. Every
> program returns an exit value (integer) when it
> exits. 0 means not
> error, anything else is an error value and the
> specific number can mean
> the type of error if its documented and the caller
> knows what to expect.
>
> > and also when we say exit(0) or exit(1) then there
> is
> > anyway to catch these values
> >
>
> From the caller you can catch this value, read the
> documentation for
> your shell about the return value. I think its $?
> under bash.
>
> > also when we return from main fn then what is the
> > benfit?
> >
> > does it have any utilisation?
> >
>
> main is just another function almost like any other
> in your
> program. The system doesn't look for the function
> main to run, its just
> a convention used by c (in windows the main function
> is called winmain
> for example, don't remember what its called in
> pascal, but IIRC
> something different also).
>
> when you compile your program its linked with some
> assembler code that
> handles setting up you environment. The system looks
> for a symbol in
> your program called _start and start the execution
> from there. This
> function is responsible for setting everything up,
> including argc and
> argv (the command line arguments and environment
> variables) and possibly
> handling calling constructors of global classes in
> c++ (not sure about
> that though). It then calls your main function with
> the proper values
> of argc and argv.
>
> When you main function returns, or when you call
> exit, a function called
> exit is called which handles all the cleaning up of
> your program and
> then the function _exit is called to finish exiting
> the program. You
> are not supposed to call _exit directly since it
> bypasses cleaning up,
> calling it directly is only useful if you use vfork
> where you don't
> want any cleaning up done since it messes things up
> (you shouldn't use
> vfork for most things nowadays since fork has almost
> no more
> overhead. If you don't know you need it, then you
> don't).
>
> > thanks
> >
> > ankit
> >
> >
>
________________________________________________________________________
> > Yahoo! Messenger - Communicate instantly..."Ping"
> > your friends today! Download Messenger Now
> > http://uk.messenger.yahoo.com/download/index.html
> > -
> > To unsubscribe from this list: send the line
> "unsubscribe linux-c-programming" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> >
> > +++++++++++++++++++++++++++++++++++++++++++
> > This Mail Was Scanned By Mail-seCure System
> > at the Tel-Aviv University CC.
> >
> -
> To unsubscribe from this list: send the line
> "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at
> http://vger.kernel.org/majordomo-info.html
>
this could also be the reason:
if we r working with child and parent procees then as
child get terminated it has to pas some status to the
parent that is going to exit then by using exit(42)
child give information to the parent that it is goig
to exit now having status 42.
thanx
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
prev parent reply other threads:[~2004-09-25 10:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-24 11:57 exit(42) Ankit Jain
2004-09-24 12:13 ` exit(42) Alphex Kaanoken
2004-09-24 12:25 ` exit(42) Ron Michael Khu
2004-09-27 9:16 ` exit(42) Pankaj
2004-09-27 12:39 ` exit(42) Micha Feigin
2004-09-27 13:54 ` exit(42) Jon Masters
2004-09-24 12:29 ` exit(42) Luciano Moreira - igLnx
2004-09-24 16:33 ` exit(42) Jan-Benedict Glaw
2004-09-25 1:13 ` exit(42) Micha Feigin
2004-09-25 10:57 ` rinku rathore [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040925105736.71615.qmail@web53005.mail.yahoo.com \
--to=rinku_ques@yahoo.com \
--cc=linux-c-programming@vger.kernel.org \
--cc=michf@post.tau.ac.il \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).