What is the difference between using _exit() & exit() in a conventional Linux fork-exec?

前端 未结 4 1755
梦谈多话
梦谈多话 2020-11-29 21:54

I\'ve been trying to figure out how the fork-exec mechanism is used inside Linux. Everything was going on according to the plan until some web pages started to confuse me.<

4条回答
  •  孤街浪徒
    2020-11-29 22:59

    exit() is on the top of _exit(), using conventional C library.

    There are the differences:

    1. _exit() won't flushes the stdio buffer while exit() flushes the stdio buffer prior to exit.

    2. _exit() can not perform clean-up process while exit() can be registered with some function ( i.e on_exit or at_exit) to perform some clean-up process if anything is required before existing the program.

    exit(status) simply passes the exit status to _exit(status). It is recommended that whenever to perform fork(), one of them between child and parent, one use _exit() and another use exit().

提交回复
热议问题