Sha256: e0c0bd1085fe8da99d22d34a3e54d1b5685bb264e3932020b222ce197dcd652b

Contents?: true

Size: 744 Bytes

Versions: 51

Compression:

Stored size: 744 Bytes

Contents

/*
 * Copyright (c) 2015 Lars Kanis. All rights reserved.
 *
 * For licensing, see LICENSE.SPECS
 */

#ifndef _WIN32
#include <unistd.h>
#include <sys/time.h>
#include "PipeHelper.h"

int pipeHelperCreatePipe(FD_TYPE pipefd[2])
{
    return pipe(pipefd);
}

char pipeHelperReadChar(FD_TYPE fd, int timeout)
{
    char d;
    struct timeval time = {timeout, 0}; // timeout after x seconds
    fd_set read_fds;
    FD_ZERO(&read_fds);
    FD_SET(fd, &read_fds);

    if(select(fd + 1, &read_fds, NULL, NULL, &time) <= 0)
        return 0;

    if( read(fd, &d, 1) != 1)
        return 0;
    return d;
}

int pipeHelperWriteChar(FD_TYPE fd, char c)
{
    return write(fd, &c, 1);
}

void pipeHelperClosePipe(FD_TYPE fd) {
    close(fd);
}
#endif

Version data entries

51 entries across 49 versions & 8 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/fixtures/PipeHelperPosix.c
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/ffi-1.9.18/spec/ffi/fixtures/PipeHelperPosix.c
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.5.0/gems/ffi-1.9.18/spec/ffi/fixtures/PipeHelperPosix.c
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/fixtures/PipeHelperPosix.c
ffi-1.9.21-x86-mingw32 spec/ffi/fixtures/PipeHelperPosix.c
ffi-1.9.21-x64-mingw32 spec/ffi/fixtures/PipeHelperPosix.c
ffi-1.9.21 spec/ffi/fixtures/PipeHelperPosix.c
tdiary-5.0.7 vendor/bundle/gems/ffi-1.9.18/spec/ffi/fixtures/PipeHelperPosix.c
comiditaULL-0.1.1 vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/spec/ffi/fixtures/PipeHelperPosix.c
comidita_ull-0.1.1 vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/spec/ffi/fixtures/PipeHelperPosix.c
comidita_ull-0.1.0 vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/spec/ffi/fixtures/PipeHelperPosix.c
vagrant-unbundled-2.0.1.0 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/fixtures/PipeHelperPosix.c
cloudsmith-api-0.21.4 vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/spec/ffi/fixtures/PipeHelperPosix.c
tdiary-5.0.6 vendor/bundle/gems/ffi-1.9.18/spec/ffi/fixtures/PipeHelperPosix.c
vagrant-unbundled-2.0.0.1 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/fixtures/PipeHelperPosix.c
vagrant-unbundled-1.9.8.1 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/fixtures/PipeHelperPosix.c
vagrant-unbundled-1.9.7.1 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/fixtures/PipeHelperPosix.c
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/ffi-1.9.18/spec/ffi/fixtures/PipeHelperPosix.c
tdiary-5.0.5 vendor/bundle/gems/ffi-1.9.18/spec/ffi/fixtures/PipeHelperPosix.c
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/fixtures/PipeHelperPosix.c