! * Function: write_n * Writes `length` bytes to the file descriptor `fd` * from the buffer `buf`. * Parameters: * [in] fd : The file descriptotr to write to. * [in] buf: Buffer from which data needs to be written to fd. * [in] length: The number of bytes that needs to be written from * `buf` to `fd`. * [out] int : Number of bytes written or -1 in case of fa
| 641 | * [out] int : Number of bytes written or -1 in case of failure. |
| 642 | */ |
| 643 | static inline |
| 644 | int write_n(int fd, const char* buf, size_t length) |
| 645 | { |
| 646 | size_t nwritten = 0; |
| 647 | while (nwritten < length) { |
| 648 | int written = subprocess_write(fd, buf + nwritten, length - nwritten); |
| 649 | if (written == -1) return -1; |
| 650 | nwritten += written; |
| 651 | } |
| 652 | return nwritten; |
| 653 | } |
| 654 | |
| 655 | |
| 656 | /*! |