int qemu_create_pidfile(const char *filename)

{

    char buffer[128];

    int len;

    int fd;



    fd = qemu_open(filename, O_RDWR | O_CREAT, 0600);

    if (fd == -1) {

        return -1;

    }

    if (lockf(fd, F_TLOCK, 0) == -1) {

        close(fd);

        return -1;

    }

    len = snprintf(buffer, sizeof(buffer), FMT_pid "\n", getpid());

    if (write(fd, buffer, len) != len) {

        close(fd);

        return -1;

    }



    close(fd);

    return 0;

}

int qemu_create_pidfile(const char *filename)

{

    char buffer[128];

    int len;

    int fd;



    fd = qemu_open(filename, O_RDWR | O_CREAT, 0600);

    if (fd == -1) {

        return -1;

    }

    if (lockf(fd, F_TLOCK, 0) == -1) {

        close(fd);

        return -1;

    }

    len = snprintf(buffer, sizeof(buffer), FMT_pid "\n", getpid());

    if (write(fd, buffer, len) != len) {

        close(fd);

        return -1;

    }



    close(fd);

    return 0;

}

    close(fd);
int FUNC_0(const char *VAR_0)

{

    char VAR_1[128];

    int VAR_2;

    int VAR_3;



    VAR_3 = qemu_open(VAR_0, O_RDWR | O_CREAT, 0600);

    if (VAR_3 == -1) {

        return -1;

    }

    if (lockf(VAR_3, F_TLOCK, 0) == -1) {

        close(VAR_3);

        return -1;

    }

    VAR_2 = snprintf(VAR_1, sizeof(VAR_1), FMT_pid "\n", getpid());

    if (write(VAR_3, VAR_1, VAR_2) != VAR_2) {

        close(VAR_3);

        return -1;

    }



    close(VAR_3);

    return 0;

}

int FUNC_0(const char *VAR_0)
{ char VAR_1[128]; int VAR_2; int VAR_3; VAR_3 = qemu_open(VAR_0, O_RDWR | O_CREAT, 0600); if (VAR_3 == -1) { return -1; } if (lockf(VAR_3, F_TLOCK, 0) == -1) { close(VAR_3); return -1; } VAR_2 = snprintf(VAR_1, sizeof(VAR_1), FMT_pid "\n", getpid()); if (write(VAR_3, VAR_1, VAR_2) != VAR_2) { close(VAR_3); return -1; } close(VAR_3); return 0; }