summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-05-17 06:20:54 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:16:50 -0500
commitb5d44d40402652291c509c2956caef90fdb2c224 (patch)
treef29ac884608dcef5ea915aa4acb86a585df8af5b
parent57bbd16b4172ce53cc631cb4d66918f9a9e8f6ba (diff)
downloadsamba-b5d44d40402652291c509c2956caef90fdb2c224.tar.gz
samba-b5d44d40402652291c509c2956caef90fdb2c224.tar.bz2
samba-b5d44d40402652291c509c2956caef90fdb2c224.zip
r6846: make smbd terminate immediately on EOF from stdin
this will be used to make sure 'make test' kills smbd when finished (This used to be commit ddbb5495637ec0d693079bc94010ab91201a07b7)
-rw-r--r--source4/smbd/server.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/source4/smbd/server.c b/source4/smbd/server.c
index d6f2afdaea..d30bcd6648 100644
--- a/source4/smbd/server.c
+++ b/source4/smbd/server.c
@@ -125,6 +125,19 @@ static void setup_signals(void)
/*
+ handle io on stdin
+*/
+static void server_stdin_handler(struct event_context *event_ctx, struct fd_event *fde,
+ uint16_t flags, void *private)
+{
+ uint8_t c;
+ if (read(0, &c, 1) == 0) {
+ DEBUG(0,("EOF on stdin - terminating\n"));
+ exit(0);
+ }
+}
+
+/*
main server.
*/
static int binary_smbd_main(int argc, const char *argv[])
@@ -200,6 +213,9 @@ static int binary_smbd_main(int argc, const char *argv[])
should hang off that */
event_ctx = event_context_init(NULL);
+ /* catch EOF on stdin */
+ event_add_fd(event_ctx, event_ctx, 0, EVENT_FD_READ, server_stdin_handler, NULL);
+
DEBUG(0,("Using %s process model\n", model));
status = server_service_startup(event_ctx, model, lp_server_services());
if (!NT_STATUS_IS_OK(status)) {