X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=include%2Fshare.h;fp=include%2Fshare.h;h=f674f31f590719915398d56d464e7684b7ddaf14;hb=fbca6b624335eef18c8d86194aeb101a720168f4;hp=0000000000000000000000000000000000000000;hpb=93d0f2eaff675059588e958e3de74a1bb7dd4028;p=ust.git diff --git a/include/share.h b/include/share.h new file mode 100644 index 0000000..f674f31 --- /dev/null +++ b/include/share.h @@ -0,0 +1,34 @@ +#ifndef UST_SHARE_H +#define UST_SHARE_H + +#include +#include + +/* This write is patient because it restarts if it was incomplete. + */ + +static inline ssize_t patient_write(int fd, const void *buf, size_t count) +{ + const char *bufc = (const char *) buf; + int result; + + for(;;) { + result = write(fd, bufc, count); + if(result == -1 && errno == EINTR) { + continue; + } + if(result <= 0) { + return result; + } + count -= result; + bufc += result; + + if(count == 0) { + break; + } + } + + return bufc-(const char *)buf; +} + +#endif /* UST_SHARE_H */