}
if (-1 == fd)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
(flags == GNUNET_DISK_OPEN_READ)
? _("Failed to open named pipe `%s' for reading: %s\n")
: _("Failed to open named pipe `%s' for writing: %s\n"),
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct GNUNET_DISK_FileHandle *control_pipe = cls;
- int sig;
-
+ char sig;
+ ssize_t ret;
+
LOG (GNUNET_ERROR_TYPE_DEBUG, "`%s' invoked because of %d\n", __FUNCTION__,
tc->reason);
- if (tc->reason &
- (GNUNET_SCHEDULER_REASON_SHUTDOWN | GNUNET_SCHEDULER_REASON_TIMEOUT |
- GNUNET_SCHEDULER_REASON_PREREQ_DONE))
+ if (0 != (tc->reason &
+ (GNUNET_SCHEDULER_REASON_SHUTDOWN | GNUNET_SCHEDULER_REASON_TIMEOUT)))
{
GNUNET_DISK_file_close (control_pipe);
+ control_pipe = NULL;
return;
}
- if (GNUNET_DISK_file_read (control_pipe, &sig, sizeof (sig)) !=
- sizeof (sig))
+ ret = GNUNET_DISK_file_read (control_pipe, &sig, sizeof (sig));
+ if (sizeof (sig) != ret)
{
- LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read");
+ if (-1 == ret)
+ LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read");
GNUNET_DISK_file_close (control_pipe);
+ control_pipe = NULL;
return;
}
LOG (GNUNET_ERROR_TYPE_DEBUG, "Got control code %d from parent\n", sig);
GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
control_pipe, &parent_control_handler,
control_pipe);
- raise (sig);
+ raise ((int) sig);
}
GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig)
{
int ret;
+ char csig;
+ csig = (char) sig;
#if !WINDOWS
if ( (NULL == proc->control_pipe) &&
(NULL != proc->childpipename) )
proc->control_pipe = npipe_open (proc->childpipename,
GNUNET_DISK_OPEN_WRITE);
#endif
- if (NULL == proc->control_pipe)
+ if (NULL != proc->control_pipe)
{
-#if WINDOWS
- /* no pipe and windows? can't do this */
- errno = EINVAL;
- return -1;
-#else
- return kill (proc->pid, sig);
-#endif
+ ret = GNUNET_DISK_file_write (proc->control_pipe, &csig, sizeof (csig));
+ if (ret == sizeof (csig))
+ return 0;
}
- ret = GNUNET_DISK_file_write (proc->control_pipe, &sig, sizeof (sig));
- if (ret == sizeof (sig))
- return 0;
- /* pipe failed, try other methods */
+ /* pipe failed or non-existent, try other methods */
switch (sig)
{
#if !WINDOWS
errno = EINVAL;
return -1;
#else
- return kill (proc->pid, sig);
+ return PLIBC_KILL (proc->pid, sig);
#endif
}
}
}
+/**
+ * Cleans up process structure contents (OS-dependent) and deallocates it
+ *
+ * @param proc pointer to process structure
+ */
void
-GNUNET_OS_process_close (struct GNUNET_OS_Process *proc)
+GNUNET_OS_process_destroy (struct GNUNET_OS_Process *proc)
{
if (NULL != proc->control_pipe)
GNUNET_DISK_file_close (proc->control_pipe);
static char *
CreateCustomEnvTable (char **vars)
{
- char *win32_env_table, *ptr, **var_ptr, *result, *result_ptr;
+ char *win32_env_table;
+ char *ptr;
+ char **var_ptr;
+ char *result;
+ char *result_ptr;
size_t tablesize = 0;
size_t items_count = 0;
- size_t n_found = 0, n_var;
+ size_t n_found = 0;
+ size_t n_var;
char *index = NULL;
size_t c;
size_t var_len;
/**
- * Retrieve the status of a process
+ * Retrieve the status of a process, waiting on him if dead.
+ * Nonblocking version.
+ *
* @param proc process ID
* @param type status type
* @param code return code/signal number
}
(void) GNUNET_OS_process_kill (cmd->eip, SIGKILL);
GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (cmd->eip));
- GNUNET_OS_process_close (cmd->eip);
+ GNUNET_OS_process_destroy (cmd->eip);
GNUNET_DISK_pipe_close (cmd->opipe);
GNUNET_free (cmd);
}