2010-08-09 09:08:16

by Alexander Clouter

[permalink] [raw]
Subject: Re: [PATCH]exit.c: support larger exit code

"Zhang, Wei-Jovi (NSN - CN/Hangzhou)" <[email protected]> wrote:
>
> I think this is just a convention of userspace program. if program
> want to obey this convention, it should be use one-byte limition exit
> code, I agree this. so this mail thread's subject should change to "if
> program use exit code with not want to obey the convention, kernel
> should return which value?"
>
I do have to agree with you on this point, although I stand by my
thoughts on *how* you should be using the exit code. Whilst writing my
post I was thinking why in C is it 'int main()' and not 'u8 main()'.

A dig around with my Googlefu and on Wackipedia gave me nothing
either...

One thing I can think of why the kernel is forcing a one byte return
code is that:
* guarantee there is no endian issue; hard to pull off though but I
guess that exit code could travel across IP to another
architecture
* stop people abusing the exitcode :)

There is probably a deeper reason as errno.h/errno-base.h all seem to be
one byte return codes too. I'm starting to ponder if that top three
bytes are meant to carry some other information?

Cheers

--
Alexander Clouter
.sigmonster says: Make sure your code does nothing gracefully.


2010-08-09 10:43:09

by Alan

[permalink] [raw]
Subject: Re: [PATCH]exit.c: support larger exit code

> There is probably a deeper reason as errno.h/errno-base.h all seem to be
> one byte return codes too. I'm starting to ponder if that top three
> bytes are meant to carry some other information?

man 2 wait

and also note that int was 16bits in the times when Unix wait/exit
behaviour was formulated.

Alan