Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/rump_allserver Reboot when killed (does cleanup).
details: https://anonhg.NetBSD.org/src/rev/d8a1510339c4
branches: trunk
changeset: 759549:d8a1510339c4
user: pooka <pooka%NetBSD.org@localhost>
date: Sun Dec 12 18:32:47 2010 +0000
description:
Reboot when killed (does cleanup).
diffstat:
usr.bin/rump_allserver/rump_allserver.c | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
diffs (57 lines):
diff -r 5351c057ae6c -r d8a1510339c4 usr.bin/rump_allserver/rump_allserver.c
--- a/usr.bin/rump_allserver/rump_allserver.c Sun Dec 12 18:21:21 2010 +0000
+++ b/usr.bin/rump_allserver/rump_allserver.c Sun Dec 12 18:32:47 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rump_allserver.c,v 1.3 2010/12/12 12:49:37 pooka Exp $ */
+/* $NetBSD: rump_allserver.c,v 1.4 2010/12/12 18:32:47 pooka Exp $ */
/*-
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@@ -27,15 +27,18 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: rump_allserver.c,v 1.3 2010/12/12 12:49:37 pooka Exp $");
+__RCSID("$NetBSD: rump_allserver.c,v 1.4 2010/12/12 18:32:47 pooka Exp $");
#endif /* !lint */
#include <sys/types.h>
+#include <sys/signal.h>
#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
#include <err.h>
#include <errno.h>
+#include <semaphore.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -59,6 +62,14 @@
exit(1);
}
+static sem_t sigsem;
+static void
+sigreboot(int sig)
+{
+
+ sem_post(&sigsem);
+}
+
int
main(int argc, char *argv[])
{
@@ -104,5 +115,11 @@
if (!sflag)
rump_daemonize_done(RUMP_DAEMONIZE_SUCCESS);
- pause();
+ sem_init(&sigsem, 0, 0);
+ signal(SIGTERM, sigreboot);
+ signal(SIGINT, sigreboot);
+ sem_wait(&sigsem);
+
+ rump_sys_reboot(0, NULL);
+ return 0;
}
Home |
Main Index |
Thread Index |
Old Index