間違いだらけの備忘録

このページの内容は無保証でありこのページの内容によって直接、または間接に損害を受けられたとしても私は責任を取りません。

リターンコード-1が255になる

$ cat exitcodetest.c 
int main()
    {
        return -1;
    }
$ gcc exitcodetest.c 
$ ./a.out 
$ echo $?
255

https://unix.stackexchange.com/questions/37915/why-do-i-get-error-255-when-returning-1

UNIX/POSIX, the exit code of a program is defined to be an unsigned 8-bit value. Converting -1 to unsigned 8-bit gives 255.

http://man7.org/linux/man-pages/man2/execve.2.html

On success, execve() does not return, on error -1 is returned

めも、素敵〜

このページにはhatena以外のサービスからのコンテンツが埋め込まれています。 hatenaによりGoogle AdSense 広告が埋め込まれています。