:: Re: [DNG] Please keep 32-bits alive
Pàgina inicial
Delete this message
Reply to this message
Autor: Robert Marmorstein
Data:  
A: dng
Assumpte: Re: [DNG] Please keep 32-bits alive
> Wouldn't this work? (no error checking of course XD)
>
>     off_t lseek(int fd, off_t offset, int whence);
>     ssize_t write(int fd, const void *buf, size_t count);

>
>     ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset) {
>         lseek(fd, offset, SEEK_SET);
>         return write(fd, buf, count);
>     }

>


Actually, no. There's a subtle difference in that the pwrite system call
combines the seek and write functions into one -atomic- operation. That means
that it can't be interrupted (for instance if the current process is suspended
or in a multi-threaded environment). This can avoid potential data loss when
multiple threads/processes are writing to the same file.