summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2011-08-10 08:59:44 -0400
committerAndreas Schneider <asn@samba.org>2011-08-10 18:14:05 +0200
commitdd4ff4bfdd3338bc5102fdcdcfea75dc9cf0be8a (patch)
tree3f30f725154531ea778d1061a9ec72c3fc7bfe7a
parentbefc53927363b6619ef306da56c4a5d15dfa8ed2 (diff)
downloadsamba-dd4ff4bfdd3338bc5102fdcdcfea75dc9cf0be8a.tar.gz
samba-dd4ff4bfdd3338bc5102fdcdcfea75dc9cf0be8a.tar.bz2
samba-dd4ff4bfdd3338bc5102fdcdcfea75dc9cf0be8a.zip
s3-printing: Add child handler to bq process
The cups backend forks a child to do asynchronous work. We need a sigchld handler in bq to properly wait for the chilod to finish and reap it, otherwise it hangs the forever as a zombie process. Signed-off-by: Andreas Schneider <asn@samba.org>
-rw-r--r--source3/printing/queue_process.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/source3/printing/queue_process.c b/source3/printing/queue_process.c
index 1b7b4f8579..20f1a5b06b 100644
--- a/source3/printing/queue_process.c
+++ b/source3/printing/queue_process.c
@@ -142,6 +142,35 @@ static void bq_setup_sig_hup_handler(struct tevent_context *ev,
}
}
+static void bq_sig_chld_handler(struct tevent_context *ev_ctx,
+ struct tevent_signal *se,
+ int signum, int count,
+ void *siginfo, void *pvt)
+{
+ int status;
+ pid_t pid;
+
+ pid = sys_waitpid(-1, &status, WNOHANG);
+ if (WIFEXITED(status)) {
+ DEBUG(6, ("Bq child process %d terminated with %d\n",
+ (int)pid, WEXITSTATUS(status)));
+ } else {
+ DEBUG(3, ("Bq child process %d terminated abnormally\n",
+ (int)pid));
+ }
+}
+
+static void bq_setup_sig_chld_handler(struct tevent_context *ev_ctx)
+{
+ struct tevent_signal *se;
+
+ se = tevent_add_signal(ev_ctx, ev_ctx, SIGCHLD, 0,
+ bq_sig_chld_handler, NULL);
+ if (!se) {
+ exit_server("failed to setup SIGCHLD handler");
+ }
+}
+
static void bq_smb_conf_updated(struct messaging_context *msg_ctx,
void *private_data,
uint32_t msg_type,
@@ -235,14 +264,11 @@ pid_t start_background_queue(struct tevent_context *ev,
bq_reopen_logs(logfile);
bq_setup_sig_term_handler();
bq_setup_sig_hup_handler(ev, msg_ctx);
+ bq_setup_sig_chld_handler(ev);
BlockSignals(false, SIGTERM);
BlockSignals(false, SIGHUP);
- if (!pcap_cache_loaded()) {
- pcap_cache_reload(ev, msg_ctx, &reload_printers);
- }
-
if (!printing_subsystem_queue_tasks(ev, msg_ctx)) {
exit(1);
}
@@ -269,6 +295,8 @@ pid_t start_background_queue(struct tevent_context *ev,
smb_panic("tevent_add_fd() failed for pause_pipe");
}
+ pcap_cache_reload(ev, msg_ctx, &reload_pcap_change_notify);
+
DEBUG(5,("start_background_queue: background LPQ thread waiting for messages\n"));
ret = tevent_loop_wait(ev);
/* should not be reached */