Deshim VirtualExecutor in folly
[hiphop-php.git] / hphp / util / sync-signal.h
blob040aa70678c2aebcae4b2c885a0cca40ace2495e
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #pragma once
19 #include <cstdint>
20 #include <pthread.h>
21 #include <signal.h>
23 namespace HPHP {
25 using sighandler_sync_t = void(*)(int);
26 using sigaction_sync_t = void(*)(int, siginfo_t*);
28 // Similar to signal(), but allows non-async-signal-safe functions to be used in
29 // handlers. Return false upon failure.
30 bool sync_signal(int signo, sighandler_sync_t h = nullptr);
32 // Synchronous signal handling for sigaction() style handlers.
33 bool sync_signal_info(int signo, sigaction_sync_t h = nullptr);
35 // Block signals that we plan to handle synchronously, and start the thread to
36 // process the signals.
37 void block_sync_signals_and_start_handler_thread();
39 // Unblock sync signals and handle them using the default handlers, instead of
40 // in the thread.
41 void reset_sync_signals();
43 // Unblock sync signals and ignore them (instead of handing them with the
44 // default hander).
45 void ignore_sync_signals();
47 // Whether a signal is intended to be forwarded to PHP code.
48 bool is_sync_signal(int signo);
50 // Restart the signal handler thread in the child process after fork. Only used
51 // when the child process will continue running HHVM, e.g., pcntl_fork().
52 void postfork_restart_handler_thread();