[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: Help please!!
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.