+/* Copyright (C) 2009 Pierre-Marc Fournier
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
#define _GNU_SOURCE
#include <sys/types.h>
#include <signal.h>
return retval;
}
-static void signal_process(pid_t pid)
+static int signal_process(pid_t pid)
{
int result;
result = kill(pid, UST_SIGNAL);
if(result == -1) {
PERROR("kill");
- return;
+ return -1;
}
/* FIXME: should wait in a better way */
- sleep(1);
+ //sleep(1);
+
+ return 0;
}
static int send_message_fd(int fd, const char *msg)
return -1;
}
- if(signalpid >= 0)
- signal_process(signalpid);
+ if(signalpid >= 0) {
+ result = signal_process(signalpid);
+ if(result == -1) {
+ ERR("could not signal process");
+ return -1;
+ }
+ }
result = connect(fd, (struct sockaddr *)&addr, sizeof(addr));
if(result == -1) {
idx++;
}
- result = poll(fds, n_fds, timeout);
+ while((result = poll(fds, n_fds, timeout)) == -1 && errno == EINTR)
+ /* nothing */;
if(result == -1) {
PERROR("poll");
return -1;
return -1;
}
- if(signalpid >= 0)
- signal_process(signalpid);
+ if(signalpid >= 0) {
+ result = signal_process(signalpid);
+ if(result == -1) {
+ ERR("could not signal process");
+ return -1;
+ }
+ }
result = connect(fd, (struct sockaddr *)&addr, sizeof(addr));
if(result == -1) {