summaryrefslogtreecommitdiff
path: root/source3/printing/queue_process.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2011-08-08 10:08:46 -0400
committerAndreas Schneider <asn@samba.org>2011-08-10 18:14:05 +0200
commitf00681fe9a78e5c0b02daff2fd83a568f8d95eff (patch)
tree80c0f5edb3712e40734e74dc580fb69c1b52058e /source3/printing/queue_process.c
parent6f682be2ae27d0f6b087a315a10f3c02cc385b66 (diff)
downloadsamba-f00681fe9a78e5c0b02daff2fd83a568f8d95eff.tar.gz
samba-f00681fe9a78e5c0b02daff2fd83a568f8d95eff.tar.bz2
samba-f00681fe9a78e5c0b02daff2fd83a568f8d95eff.zip
s3-printing: make sure to block SIGHUP ...
... until we are ready to handle it. Also make us ready as early as possible in spoolssd. Signed-off-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/printing/queue_process.c')
-rw-r--r--source3/printing/queue_process.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/source3/printing/queue_process.c b/source3/printing/queue_process.c
index a56baaf6b7..1b7b4f8579 100644
--- a/source3/printing/queue_process.c
+++ b/source3/printing/queue_process.c
@@ -191,8 +191,24 @@ pid_t start_background_queue(struct tevent_context *ev,
exit(1);
}
+ /*
+ * Block signals before forking child as it will have to
+ * set its own handlers. Child will re-enable SIGHUP as
+ * soon as the handlers are set up.
+ */
+ BlockSignals(true, SIGTERM);
+ BlockSignals(true, SIGHUP);
+
pid = sys_fork();
+ /* parent or error */
+ if (pid != 0) {
+ /* Re-enable SIGHUP before returnig */
+ BlockSignals(false, SIGTERM);
+ BlockSignals(false, SIGHUP);
+ return pid;
+ }
+
if (pid == -1) {
DEBUG(5,("start_background_queue: background LPQ thread failed to start. %s\n", strerror(errno) ));
exit(1);
@@ -220,6 +236,9 @@ pid_t start_background_queue(struct tevent_context *ev,
bq_setup_sig_term_handler();
bq_setup_sig_hup_handler(ev, msg_ctx);
+ BlockSignals(false, SIGTERM);
+ BlockSignals(false, SIGHUP);
+
if (!pcap_cache_loaded()) {
pcap_cache_reload(ev, msg_ctx, &reload_printers);
}