While dozniak is right in saying that syscall_exit should be a noreturn, he's only scratching the surface.
In all implementations that I've seen, exit generally calls _exit (or its equivalent _Exit), that has two jobs and two jobs only: make the syscall to terminate the process (this usually includes cleanup like closing open file descriptors, etc.) and never return, hence the _Noreturn keyword. In other words, the syscall to terminate a process should not return in the first place; the line
Code:
return syscall_exit(code);
is a contradiction in itself.
My C11 spec says that exit(3) should look like this:
Code:
_Noreturn void exit(int status);
Here's the description (see 7.22.4.4):
C11 spec wrote:
The exit function causes normal program termination to occur. No functions registered by the at_quick_exit function are called. If a program calls the exit function more than once, or calls the quick_exit function in addition to the exit function, the behavior is undefined.
As for _exit(3), it should be declared as
Code:
_Noreturn void _Exit(int status);
The description is pretty similar:
C11 spec wrote:
The _Exit function causes normal program termination to occur and control to be returned to the host environment. No functions registered by the atexit function, the at_quick_exit function, or signal handlers registered by the signal function are called. The status returned to the host environment is determined in the same way as for the exit function (7.22.4.4). Whether open streams with unwritten buffered data are flushed, open streams are closed, or temporary files are removed is implementation-defined.
Long story short: whatever you are doing right there is not standard-compliant nor sensible (Think about it: your exit syscall doesn't terminate the program?)