pgubook-readers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pgubook-readers] Chapter 4. Max value for exit sys call in Linux


From: rmbd91
Subject: [Pgubook-readers] Chapter 4. Max value for exit sys call in Linux
Date: Sun, 01 Sep 2019 00:02:24 +0300

Hello!

My name is Anton.

Firstly, thank you very much for such a great book!
Reading it right now and trying to do exercises.

Secondly, just wanted to share my finding, may be a note about this problem will be added to the book sometime and will save some time for new readers.

When I was testing program with square function I noticed that at some input values program's exit codes were not correct (program was returning squared value by return code of exit system call).

Here is the listing:

.section .text
.globl _start
_start:
pushl $30
call square
addl $4, %esp
movl %eax, %ebx
movl $1, %eax
int $0x80

square:
pushl %ebp
movl %esp, %ebp
movl 8(%ebp), %eax
imull %eax, %eax
movl %ebp, %esp
popl %ebp
ret

return code was 127 (0x84), but it should be 900 (0x384).

And the problem was that it is limitation of bash (only 1 byte for exit codes - 0-255) and more accurately described at link below:
https://unix.stackexchange.com/questions/418784/what-is-the-min-and-max-values-of-exit-codes-in-linux

Sincerely yours,
Anton
reply via email to

[Prev in Thread] Current Thread [Next in Thread]