How come _exit(0) (exiting by syscall) prevents me from receiving any stdout content?

前端 未结 3 1073
你的背包
你的背包 2021-01-19 03:12

I have a Linux x86-32 GAS assembly program terminating like this:

movl $1, %eax
movl $0, %ebx # argument for _exit
int $0x80

When I exit li

3条回答
  •  情话喂你
    2021-01-19 03:45

    Output sent to standard out is usually buffered. If you call fflush(stdout) before you call _exit you should get your output.

    The reason exit works is because that function is guaranteed to close and flush any open streams (such as stdout) before calling _exit itself to actually terminate the program.

提交回复
热议问题