[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: Help please!!



Hi,
The exit status of a routine will be always what it returns (thru return
statement) or else it will be zero. In case of the C-program, the exit status
(to the shell which invokes the routine) will be the returned value ( thru
'return' command) or else it will be zero.

----regards,
rk patil

"Satheesh Kumar. N.K" wrote:

> I doubt if the exit() status is same as return value. This prompts me to post
> this question on the list.
>
> Consider a program whose normal return value is expected to be, say 1.
> The exit status will be 0 indicating that the program terminated normally.
> These two differ. Please correct me if I'm wrong.
>
> Your answer that the shell var $? may be the right answer for my question.
> Any more thoughts on the same?
>
> --Satheesh
>
> Kedar Patankar wrote:
>
> > > I have a doubt with C.
> > > If the function main() returns a value with return x; - who gets this
> > > return
> > > value? Is this return value stored somewhere?
> > > Also, who invokes function main()?
> >
> >         I don't think there is a platform agnostic answer. AFAIK, on posix
> > systems, the parent of your process can get the status returned by your
> > main(). All he has to do is use one of those "wait" calls and get the
> > status of your exit.
> >         In a decent shell, this value is normally available as "$?", that
> > you can use to make decisions in shell scripts about the success/failure
> > of the program.
> >
> >         Regards,
> >         Kedar.
> >
> > -----------------------------------------------------------------------
> > LIP is all for free speech.  But it was created for a purpose - to help
> > people discuss technical programming related issues about Linux.  If
> > your messages are counterproductive to this purpose, your privileges to
> > submit messages can and will be revoked.
>
> -----------------------------------------------------------------------
> For more information on the LIP mailing list see:
> http://lists.linux-india.org/lists/LIP

--
---regards,
---------------------------------------------------------------------
RK Patil
Accord Software and Systems Pvt. Ltd.
Tele: +91-80-5560136/38  Fax :+91-80-5542723
Visit : www.accord-soft.com