Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

writev(2) seems not to set file pos correctly #420

Closed
unak opened this issue May 24, 2016 · 3 comments
Closed

writev(2) seems not to set file pos correctly #420

unak opened this issue May 24, 2016 · 3 comments

Comments

@unak
Copy link

unak commented May 24, 2016

Reproduce code (writev.c):

#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/uio.h>

main(void)
{
    struct iovec iovec;
    int fd;

    fd = open("test.dat", O_CREAT | O_WRONLY | O_TRUNC, 0644);
    if (fd < 0) {
        perror("open");
        exit(1);
    }

    iovec.iov_base = "abcd\n";
    iovec.iov_len = 5;
    if (writev(fd, &iovec, 1) < 0) {
        perror("writev(1)");
        close(fd);
        exit(1);
    }

    iovec.iov_base = "ef\n";
    iovec.iov_len = 3;
    if (writev(fd, &iovec, 1) < 0) {
        perror("writev(2)");
        close(fd);
        exit(1);
    }

    close(fd);

    exit(0);
}

How to reproduce:

usa@METHUSS:~/tmp$ gcc writev.c
usa@METHUSS:~/tmp$ ./a.out
usa@METHUSS:~/tmp$ cat test.dat
ef
d

Expected result of cat test.dat:

abcd
ef
@benhillis
Copy link
Member

I believe that this is the same root cause as #313 which as been fixed and will be in a Windows Insider build soon.

Thank you for the detailed repro steps, I've tried them locally on our development branch and verified that it now matches the expected.

@unak
Copy link
Author

unak commented May 25, 2016

thank you for reviewing. I'm looking forward to the fixed build :)

@russalex russalex added the fixed label Jun 9, 2016
@russalex
Copy link
Contributor

russalex commented Jun 9, 2016

Looks to be fixed in 14361.

russ@DESKTOP-K1JHN54:/mnt/c/temp$ vi foo.c
russ@DESKTOP-K1JHN54:/mnt/c/temp$ gcc foo.c
russ@DESKTOP-K1JHN54:/mnt/c/temp$ ./a.out
russ@DESKTOP-K1JHN54:/mnt/c/temp$ cat test.dat
abcd
ef

Thanks for the solid repro here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants