aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2023-04-29 16:13:51 +0300
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-04-29 16:53:47 +0200
commit41aac872341fbf70f3b7006ef266eb02a354a993 (patch)
tree295d9bd4b7ca177d0e4a4022a6f076b5b63fdfbd
parenta9fb57105e9abd7919478226ee802270d1b3b9df (diff)
downloadglibc-41aac872341fbf70f3b7006ef266eb02a354a993.zip
glibc-41aac872341fbf70f3b7006ef266eb02a354a993.tar.gz
glibc-41aac872341fbf70f3b7006ef266eb02a354a993.tar.bz2
hurd: Make _exit work during early boot-up
If any of the early boot-up tasks calls exit () or returns from main (), terminate it properly instead of crashing on trying to dereference _hurd_ports and getting forcibly terminated by the kernel. We sadly cannot make the __USEPORT macro do the check for _hurd_ports being unset, because it evaluates to the value of the expression provided as the second argument, and that can be of any type; so there is no single suitable fallback value for the macro to evaluate to in case _hurd_ports is unset. Instead, each use site that wants to care for this case will have to do its own checking. Checked on x86_64-gnu. Signed-off-by: Sergey Bugaev <bugaevc@gmail.com> Message-Id: <20230429131354.2507443-4-bugaevc@gmail.com>
-rw-r--r--sysdeps/mach/hurd/_exit.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sysdeps/mach/hurd/_exit.c b/sysdeps/mach/hurd/_exit.c
index 7395774..80cfe53 100644
--- a/sysdeps/mach/hurd/_exit.c
+++ b/sysdeps/mach/hurd/_exit.c
@@ -24,8 +24,9 @@
void
_hurd_exit (int status)
{
- /* Give the proc server our exit status. */
- __USEPORT (PROC, __proc_mark_exit (port, status, 0));
+ if (_hurd_ports != NULL)
+ /* Give the proc server our exit status. */
+ __USEPORT (PROC, __proc_mark_exit (port, status, 0));
/* Commit suicide. */
__task_terminate (__mach_task_self ());