CUBRID Engine  latest
dl_daemon.c
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 /*
20  * dl_daemon.c - Daemon that scavenges for dynamic loader temp files.
21  */
22 
23 #ident "$Id$"
24 
25 #include "config.h"
26 
27 #include <stdlib.h>
28 #include <sys/param.h>
29 #include <errno.h>
30 #include <unistd.h>
31 
32 #if defined(SIGTSTP)
33 #include <sys/file.h>
34 #include <sys/ioctl.h>
35 #endif /* SIGTSTP */
36 
37 #include "porting.h"
38 
39 static char dynload_Temporary_filename[PATH_MAX] = "";
40 
41 static void dynload_install_handlers (void);
42 static void dynload_remove_temporary_file (void);
43 
44 /*
45  * dynload_remove_temporary_file() - temporary file check and remove
46  * return: none
47  */
48 static void
50 {
51  if (dynload_Temporary_filename[0] != 0)
52  {
53  int ret = access (dynload_Temporary_filename, R_OK);
54  if (ret == 0)
55  {
57  }
58  }
59 }
60 
61 
62 /*
63  * dynload_install_handlers() - Ignore the terminal stop signals.
64  * return: none
65  */
66 static void
68 {
69 #if defined(SIGTTOU)
70  (void) os_set_signal_handler (SIGTTOU, SIG_IGN);
71 #endif /* SIGTTOU */
72 #if defined(SIGTTIN)
73  (void) os_set_signal_handler (SIGTTIN, SIG_IGN);
74 #endif /* SIGTTIN */
75 #if defined(SIGTSTP)
76  (void) os_set_signal_handler (SIGTSTP, SIG_IGN);
77 #endif /* SIGTSTP */
78 
79  (void) os_set_signal_handler (SIGPIPE, SIG_IGN);
80 }
81 
82 
83 /*
84  * Whenever the dynamic loader changes its temp file (the one used to maintain
85  * symbol table information), it informs the daemon. If the dynamic loader's
86  * process dies before removing the file, the daemon will notice the fact and
87  * remove the file itself.
88  */
89 
90 void
91 main (void)
92 {
94 
95  while (read (0, dynload_Temporary_filename, sizeof (dynload_Temporary_filename)) != 0)
96  {
97  ; /* it reads from PIPE until the parent is ended */
98  }
99 
101  exit (0);
102 }
void main(void)
Definition: dl_daemon.c:91
static void dynload_install_handlers(void)
Definition: dl_daemon.c:67
static void dynload_remove_temporary_file(void)
Definition: dl_daemon.c:49
static char dynload_Temporary_filename[PATH_MAX]
Definition: dl_daemon.c:39
SIGNAL_HANDLER_FUNCTION os_set_signal_handler(const int sig_no, SIGNAL_HANDLER_FUNCTION sig_handler)
Definition: porting.c:1333