Normally applications do not directly call exit_group() but instead use
a wrapper function _exit(). However Golang system library bypasses libc and
calls sys_exit_group when handling sys.Exit() function.

Techically sys_exit() and sys_exit_group() behave slighly differently
on Linux however given OSv is a unikernel and exit() in OSv terminates
both app and kernel, it makes sense for sys_exit_group() do the same thing.

Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>
---
 linux.cc | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/linux.cc b/linux.cc
index d548db93..1eff6ffc 100644
--- a/linux.cc
+++ b/linux.cc
@@ -318,6 +318,13 @@ static int sys_exit(int ret)
     return 0;
 }
 
+#define __NR_sys_exit_group __NR_exit_group
+static int sys_exit_group(int ret)
+{
+    exit(ret);
+    return 0;
+}
+
 #define __NR_sys_ioctl __NR_ioctl
 //
 // We need to define explicit sys_ioctl that takes these 3 parameters to 
conform
@@ -421,6 +428,7 @@ long syscall(long number, ...)
     SYSCALL3(getrandom, char *, size_t, unsigned int);
     SYSCALL2(nanosleep, const struct timespec*, struct timespec *);
     SYSCALL4(fstatat, int, const char *, struct stat *, int);
+    SYSCALL1(sys_exit_group, int);
     }
 
     debug_always("syscall(): unimplemented system call %d\n", number);
-- 
2.19.1

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to