-rw-r--r-- | noncore/applets/keyhelper/keyhelperapplet/anylnk/ProcessInvoker.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/noncore/applets/keyhelper/keyhelperapplet/anylnk/ProcessInvoker.cpp b/noncore/applets/keyhelper/keyhelperapplet/anylnk/ProcessInvoker.cpp index 09605bd..ff06551 100644 --- a/noncore/applets/keyhelper/keyhelperapplet/anylnk/ProcessInvoker.cpp +++ b/noncore/applets/keyhelper/keyhelperapplet/anylnk/ProcessInvoker.cpp | |||
@@ -1,50 +1,54 @@ | |||
1 | #include "ProcessInvoker.h" | 1 | #include "ProcessInvoker.h" |
2 | 2 | ||
3 | #ifndef PIPE_BUF // uClibc or similar | ||
4 | #include <linux/limits.h> | ||
5 | #endif | ||
6 | |||
3 | static ProcessInvoker* g_this; | 7 | static ProcessInvoker* g_this; |
4 | /* ------------------------------------------------------------------------ */ | 8 | /* ------------------------------------------------------------------------ */ |
5 | /* static functions */ | 9 | /* static functions */ |
6 | /* ------------------------------------------------------------------------ */ | 10 | /* ------------------------------------------------------------------------ */ |
7 | 11 | ||
8 | static Sigfunc* setSignalHandler(int signo, Sigfunc* handler) | 12 | static Sigfunc* setSignalHandler(int signo, Sigfunc* handler) |
9 | { | 13 | { |
10 | struct sigaction act,oact; | 14 | struct sigaction act,oact; |
11 | 15 | ||
12 | act.sa_handler = handler; | 16 | act.sa_handler = handler; |
13 | ::sigemptyset(&act.sa_mask); | 17 | ::sigemptyset(&act.sa_mask); |
14 | act.sa_flags = 0; | 18 | act.sa_flags = 0; |
15 | #ifdefSA_RESTART | 19 | #ifdefSA_RESTART |
16 | act.sa_flags |= SA_RESTART; | 20 | act.sa_flags |= SA_RESTART; |
17 | #endif | 21 | #endif |
18 | if(::sigaction(signo, &act, &oact) < 0){ | 22 | if(::sigaction(signo, &act, &oact) < 0){ |
19 | return(NULL); | 23 | return(NULL); |
20 | } | 24 | } |
21 | return(oact.sa_handler); | 25 | return(oact.sa_handler); |
22 | } | 26 | } |
23 | 27 | ||
24 | static void childHandler(int /*signo*/) | 28 | static void childHandler(int /*signo*/) |
25 | { | 29 | { |
26 | pid_t pid; | 30 | pid_t pid; |
27 | int status; | 31 | int status; |
28 | while((pid = ::waitpid(-1, &status, WNOHANG)) > 0){ | 32 | while((pid = ::waitpid(-1, &status, WNOHANG)) > 0){ |
29 | if(pid == g_this->m_child){ | 33 | if(pid == g_this->m_child){ |
30 | g_this->notifyFinish(status); | 34 | g_this->notifyFinish(status); |
31 | } | 35 | } |
32 | } | 36 | } |
33 | } | 37 | } |
34 | 38 | ||
35 | /* ------------------------------------------------------------------------ */ | 39 | /* ------------------------------------------------------------------------ */ |
36 | /* ProcessInvoker Class : parent process */ | 40 | /* ProcessInvoker Class : parent process */ |
37 | /* ------------------------------------------------------------------------ */ | 41 | /* ------------------------------------------------------------------------ */ |
38 | ProcessInvoker::ProcessInvoker() | 42 | ProcessInvoker::ProcessInvoker() |
39 | { | 43 | { |
40 | g_this = this; | 44 | g_this = this; |
41 | m_isRunning = false; | 45 | m_isRunning = false; |
42 | m_child = 0; | 46 | m_child = 0; |
43 | m_defChildHandler = SIG_DFL; | 47 | m_defChildHandler = SIG_DFL; |
44 | m_pTimer = new QTimer(this); | 48 | m_pTimer = new QTimer(this); |
45 | m_stdfd[0] = m_stdfd[1] = -1; | 49 | m_stdfd[0] = m_stdfd[1] = -1; |
46 | m_errfd[0] = m_errfd[1] = -1; | 50 | m_errfd[0] = m_errfd[1] = -1; |
47 | connect(m_pTimer, SIGNAL(timeout()), | 51 | connect(m_pTimer, SIGNAL(timeout()), |
48 | this, SLOT(readOutputs())); | 52 | this, SLOT(readOutputs())); |
49 | } | 53 | } |
50 | 54 | ||