}
ret = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileHandle));
ret->h = h;
- ret->type = GNUNET_PIPE;
+ ret->type = GNUNET_DISK_HANLDE_TYPE_PIPE;
ret->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
ret->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
ret->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
ret = GNUNET_malloc (sizeof (struct GNUNET_DISK_FileHandle));
ret->h = h;
- ret->type = GNUNET_PIPE;
+ ret->type = GNUNET_DISK_HANLDE_TYPE_PIPE;
ret->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
ret->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
ret->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
return NULL; /* not executable */
if ( (GNUNET_YES == pipe_control) &&
(GNUNET_OK != npipe_setup (&childpipename)) )
- return NULL;
+ {
+ GNUNET_free (childpipename);
+ return NULL;
+ }
if (NULL != pipe_stdout)
{
GNUNET_assert (GNUNET_OK ==
fail = 1;
do
{
- int wrote;
+ ssize_t wrote;
uint64_t size;
- unsigned int count;
+ uint64_t count;
unsigned int i;
/* Tell the number of sockets */
for (count = 0; lsocks && lsocks[count] != INVALID_SOCKET; count++);
wrote = GNUNET_DISK_file_write (lsocks_write_fd, &count, sizeof (count));
- if (wrote != sizeof (count))
+ if (sizeof (count) != wrote)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to write %u count bytes to the child: %u\n", sizeof (count), GetLastError ());
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to write %u count bytes to the child: %u\n",
+ sizeof (count), GetLastError ());
break;
}
for (i = 0; lsocks && lsocks[i] != INVALID_SOCKET; i++)
/* Get a socket duplication info */
if (SOCKET_ERROR == WSADuplicateSocketA (lsocks[i], gnunet_proc->pid, &pi))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to duplicate an socket[%llu]: %u\n", i, GetLastError ());
- LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "CreateProcess");
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to duplicate an socket[%llu]: %u\n", i,
+ GetLastError ());
break;
}
/* Synchronous I/O is not nice, but we can't schedule this:
*/
size = sizeof (pi);
wrote = GNUNET_DISK_file_write (lsocks_write_fd, &size, sizeof (size));
- if (wrote != sizeof (size))
+ if (sizeof (size) != wrote)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to write %u size[%llu] bytes to the child: %u\n", sizeof (size), i, GetLastError ());
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to write %u size[%llu] bytes to the child: %u\n",
+ sizeof (size), i, GetLastError ());
break;
}
/* Finally! Send the data */
wrote = GNUNET_DISK_file_write (lsocks_write_fd, &pi, sizeof (pi));
- if (wrote != sizeof (pi))
+ if (sizeof (pi) != wrote)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to write %u socket[%llu] bytes to the child: %u\n", sizeof (pi), i, GetLastError ());
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to write %u socket[%llu] bytes to the child: %u\n",
+ sizeof (pi), i, GetLastError ());
break;
}
}
* @param pipe_stdout pipe to use to get output from child process (or NULL)
* @param filename name of the binary
* @param ... NULL-terminated list of arguments to the process
- *
* @return pointer to process structure of the new process, NULL on error
- *
*/
struct GNUNET_OS_Process *
GNUNET_OS_start_process (int pipe_control,
* Start a process.
*
* @param pipe_control should a pipe be used to send signals to the child?
+ * @param std_inheritance a set of GNUNET_OS_INHERIT_STD_* flags controlling which
+ * std handles of the parent are inherited by the child.
+ * pipe_stdin and pipe_stdout take priority over std_inheritance
+ * (when they are non-NULL).
* @param lsocks array of listen sockets to dup systemd-style (or NULL);
* must be NULL on platforms where dup is not supported
* @param filename name of the binary
/**
* Wait for a process
+ *
* @param proc pointer to process structure
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise
*/
void
GNUNET_OS_command_stop (struct GNUNET_OS_CommandHandle *cmd)
{
-
- if (cmd->proc != NULL)
+ if (NULL != cmd->proc)
{
GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != cmd->rtask);
GNUNET_SCHEDULER_cancel (cmd->rtask);
}
end = memchr (&cmd->buf[cmd->off], '\n', ret);
cmd->off += ret;
- while (end != NULL)
+ while (NULL != end)
{
*end = '\0';
cmd->proc (cmd->proc_cls, cmd->buf);
}
-
-
/* end of os_priority.c */