[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: exit(), _exit() and sys_exit()
Rajaram Suryanarayanan <rajaram_linux@xxxxxxxxx> [2006-03-04]:
> Hi,
>
> What is the difference between exit and _exit() ?
man _exit:
The function _exit() is like exit(), but does not call any
functions registered with atexit() or on_exit(). Whether it flushes
standard I/O buffers and removes temporary files created with
tmpfile(3) is implementation dependent. On the other hand, _exit()
does close open file descriptors, and this may cause an unknown delay,
wait- ing for pending output to finish. If the delay is undesired, it
may be useful to call functions like tcflush() before calling _exit().
Whether any pending I/O is can- celled, and which pending I/O may
be cancelled upon _exit(), is implementation-depen- dent.
> I studied in some google links that exit() is a C library wrapper and _exit() is the system call. Then what is sys_exit() ? The system calls should begin with "sys_" as per convention. Am I right ?
sys_exit should be the system call in the kernel. The exit() or _exit()
library functions do a syscall (software interrupt 70 on i386 and place
the syscall number in %eax) and the kernel has a syscall table where it
searches for the sycall number.
So the name is irrelevant, only the number is important. By convention,
sysalls in the kernel begin with sys_, right.
Regards,
Bernhard
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/