*/
struct GNUNET_DISK_DirectoryIterator
{
- /**
- * Our scheduler.
- */
- struct GNUNET_SCHEDULER_Handle *sched;
/**
* Function to call on directory entries.
GNUNET_DISK_directory_iterator_next (iter, GNUNET_YES);
return GNUNET_NO;
}
- GNUNET_SCHEDULER_add_with_priority (iter->sched,
- iter->priority,
+ GNUNET_SCHEDULER_add_with_priority (iter->priority,
&directory_iterator_task, iter);
return GNUNET_YES;
}
* If a scheduler does not need to be used, GNUNET_DISK_directory_scan
* may provide a simpler API.
*
- * @param sched scheduler to use
* @param prio priority to use
* @param dirName the name of the directory
* @param callback the method to call for each file
* @param callback_cls closure for callback
*/
void
-GNUNET_DISK_directory_iterator_start (struct GNUNET_SCHEDULER_Handle *sched,
- enum GNUNET_SCHEDULER_Priority prio,
+GNUNET_DISK_directory_iterator_start (enum GNUNET_SCHEDULER_Priority prio,
const char *dirName,
GNUNET_DISK_DirectoryIteratorCallback
callback, void *callback_cls)
struct GNUNET_DISK_DirectoryIterator *di;
di = GNUNET_malloc (sizeof (struct GNUNET_DISK_DirectoryIterator));
- di->sched = sched;
di->callback = callback;
di->callback_cls = callback_cls;
di->directory = OPENDIR (dirName);
#endif
}
+
/**
* Creates an interprocess channel
*
* @param blocking creates an asynchronous pipe if set to GNUNET_NO
+ * @param inherit_read inherit the parent processes stdin (only for windows)
+ * @param inherit_write inherit the parent processes stdout (only for windows)
+ *
* @return handle to the new pipe, NULL on error
*/
struct GNUNET_DISK_PipeHandle *
-GNUNET_DISK_pipe (int blocking)
+GNUNET_DISK_pipe (int blocking, int inherit_read, int inherit_write)
{
struct GNUNET_DISK_PipeHandle *p;
struct GNUNET_DISK_FileHandle *fds;
ret = pipe (fd);
if (ret == -1)
{
+ eno = errno;
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "pipe");
GNUNET_free (p);
+ errno = eno;
return NULL;
}
p->fd[0]->fd = fd[0];
p->fd[1]->fd = fd[1];
ret = 0;
flags = fcntl (fd[0], F_GETFL);
- flags |= FD_CLOEXEC;
if (!blocking)
flags |= O_NONBLOCK;
if (0 > fcntl (fd[0], F_SETFL, flags))
ret = -1;
- flags = fcntl (fd[1], F_GETFL);
+ flags = fcntl (fd[0], F_GETFD);
flags |= FD_CLOEXEC;
+ if (0 > fcntl (fd[0], F_SETFD, flags))
+ ret = -1;
+
+ flags = fcntl (fd[1], F_GETFL);
if (!blocking)
flags |= O_NONBLOCK;
if (0 > fcntl (fd[1], F_SETFL, flags))
ret = -1;
+ flags = fcntl (fd[1], F_GETFD);
+ flags |= FD_CLOEXEC;
+ if (0 > fcntl (fd[1], F_SETFD, flags))
+ ret = -1;
if (ret == -1)
{
eno = errno;
}
#else
BOOL ret;
+ HANDLE tmp_handle;
ret = CreatePipe (&p->fd[0]->h, &p->fd[1]->h, NULL, 0);
if (!ret)
SetErrnoFromWinError (GetLastError ());
return NULL;
}
+ if (!DuplicateHandle (GetCurrentProcess (), p->fd[0]->h,
+ GetCurrentProcess (), &tmp_handle, 0, inherit_read == GNUNET_YES ? TRUE : FALSE,
+ DUPLICATE_SAME_ACCESS))
+ {
+ SetErrnoFromWinError (GetLastError ());
+ CloseHandle (p->fd[0]->h);
+ CloseHandle (p->fd[1]->h);
+ GNUNET_free (p);
+ return NULL;
+ }
+ CloseHandle (p->fd[0]->h);
+ p->fd[0]->h = tmp_handle;
+
+ if (!DuplicateHandle (GetCurrentProcess (), p->fd[1]->h,
+ GetCurrentProcess (), &tmp_handle, 0, inherit_write == GNUNET_YES ? TRUE : FALSE,
+ DUPLICATE_SAME_ACCESS))
+ {
+ SetErrnoFromWinError (GetLastError ());
+ CloseHandle (p->fd[0]->h);
+ CloseHandle (p->fd[1]->h);
+ GNUNET_free (p);
+ return NULL;
+ }
+ CloseHandle (p->fd[1]->h);
+ p->fd[1]->h = tmp_handle;
if (!blocking)
{
DWORD mode;