immediately create listener thread on process creation
authorPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Tue, 13 Oct 2009 21:47:24 +0000 (17:47 -0400)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Tue, 13 Oct 2009 21:47:24 +0000 (17:47 -0400)
It is complex to create a thread properly inside a signal handler.
Leave this aside for now. This optimization can always be added
later.

libust/tracectl.c
libustcomm/ustcomm.c

index 2d4341d3b418cd4957b8ab2efc95fbf564f6520e..d4cd5942d7bed35cc0663445c6f3c713aa0a62bf 100644 (file)
@@ -798,61 +798,11 @@ void create_listener(void)
        have_listener = 1;
 }
 
-/* The signal handler itself. Signals must be setup so there cannot be
-   nested signals. */
-
-void sighandler(int sig)
-{
-       DBG("sighandler");
-
-       if(!have_listener) {
-               create_listener();
-       }
-}
-
-/* Called by the app signal handler to chain it to us. */
-
-void chain_signal(void)
-{
-       sighandler(USTSIGNAL);
-}
-
 static int init_socket(void)
 {
        return ustcomm_init_app(getpid(), &ustcomm_app);
 }
 
-static int init_signal_handler(void)
-{
-       /* Attempt to handler SIGIO. If the main program wants to
-        * handle it, fine, it'll override us. They it'll have to
-        * use the chaining function.
-        */
-
-       int result;
-       struct sigaction act;
-
-       result = sigemptyset(&act.sa_mask);
-       if(result == -1) {
-               PERROR("sigemptyset");
-               return -1;
-       }
-
-       act.sa_handler = sighandler;
-       act.sa_flags = SA_RESTART;
-
-       /* Only defer ourselves. Also, try to restart interrupted
-        * syscalls to disturb the traced program as little as possible.
-        */
-       result = sigaction(SIGIO, &act, NULL);
-       if(result == -1) {
-               PERROR("sigaction");
-               return -1;
-       }
-
-       return 0;
-}
-
 #define AUTOPROBE_DISABLED      0
 #define AUTOPROBE_ENABLE_ALL    1
 #define AUTOPROBE_ENABLE_REGEX  2
@@ -916,11 +866,8 @@ static void __attribute__((constructor)) init()
                ERR("init_socket error");
                return;
        }
-       result = init_signal_handler();
-       if(result == -1) {
-               ERR("init_signal_handler error");
-               return;
-       }
+
+       create_listener();
 
        autoprobe_val = getenv("UST_AUTOPROBE");
        if(autoprobe_val) {
index 6044c271fa7101d585261d44b1c24f401dfd2ef4..1b6843bf7d4879df38a57c946bd095d5cfd29f22 100644 (file)
@@ -67,22 +67,11 @@ char *strdup_malloc(const char *s)
 
 static int signal_process(pid_t pid)
 {
-       int result;
-
-       result = kill(pid, UST_SIGNAL);
-       if(result == -1) {
-               PERROR("kill");
-               return -1;
-       }
-
-       /* FIXME: should wait in a better way */
-       //sleep(1);
-
        return 0;
 }
 
 int pid_is_online(pid_t pid) {
-       return kill(pid, UST_SIGNAL) != -1;
+       return 1;
 }
 
 static int send_message_fd(int fd, const char *msg)
This page took 0.025174 seconds and 4 git commands to generate.