Ejemplo n.º 1
0
static int child_io_setup (struct subprocess *p)
{
    /*
     *  Close parent end of stdio in child:
     */
    if (zio_close_dst_fd (p->zio_in) < 0
            || zio_close_src_fd (p->zio_out) < 0
            || zio_close_src_fd (p->zio_err) < 0)
        return (-1);

    /*
     *  Dup this process' fds onto zio
     */
    if (  (dup2_fd (zio_src_fd (p->zio_in), STDIN_FILENO) < 0)
       || (dup2_fd (zio_dst_fd (p->zio_out), STDOUT_FILENO) < 0)
       || (dup2_fd (zio_dst_fd (p->zio_err), STDERR_FILENO) < 0))
        return (-1);

    return (0);
}
Ejemplo n.º 2
0
static int parent_io_setup (struct subprocess *p)
{
    /*
     *  Close child end of stdio in parent:
     */
    if (zio_close_src_fd (p->zio_in) < 0
            || zio_close_dst_fd (p->zio_out) < 0
            || zio_close_dst_fd (p->zio_err) < 0)
        return (-1);

    return (0);
}
Ejemplo n.º 3
0
Archivo: zio.c Proyecto: trws/flux-core
void zio_destroy (zio_t *z)
{
    if (z == NULL)
        return;
    assert (z->magic == ZIO_MAGIC);
    if (zio_is_in_handler (z)) {
        zio_set_destroyed (z);
        return;
    }
    if (z->buf)
        cbuf_destroy (z->buf);
    free (z->name);
    free (z->prefix);
    zio_close_src_fd (z);
    zio_close_dst_fd (z);
    flux_watcher_destroy (z->reader);
    flux_watcher_destroy (z->writer);
    assert ((z->magic = ~ZIO_MAGIC));
    free (z);
}
Ejemplo n.º 4
0
Archivo: zio.c Proyecto: trws/flux-core
static int zio_close (zio_t *zio)
{
    if (zio->flags & ZIO_CLOSED) {
        /* Already closed */
        errno = EINVAL;
        return (-1);
    }
    zio_debug (zio, "zio_close\n");
    if (zio_reader (zio))
        zio_close_src_fd (zio);
    else if (zio_writer (zio)) {
        zio_close_dst_fd (zio);
        /* For writer zio object, consider close(dstfd)
         *  as "EOF sent"
         */
        zio->flags |= ZIO_EOF_SENT;
    }
    zio->flags |= ZIO_CLOSED;
    if (zio->close)
        return (*zio->close) (zio, zio->arg);
    return (0);
}