write

WRITE(2)                   Linux Programmer's Manual                  WRITE(2)



NAME
       write -å¨ä¸ä¸ªæ件æ述符ä¸æ§è¡åæä½

æ¦è¿°
       #include <unistd.h>

       ssize_t write(int fd, const void *buf, size_t count);

æè¿°
       write åæ件æ述符 fd æå¼ç¨çæ件ä¸åå¥ ä» buf å¼å§çç¼å²åºä¸ count å‐
       èçæ°æ®.  POSIXè§å®,å½ä½¿ç¨äºwrite()ä¹åå使ç¨
       read(),é£ä¹è¯»åå°çåºè¯¥æ¯æ´æ°åçæ°æ®.  ä½è¯·æ³¨æ并ä¸æ¯ææçæ件系ç»é½æ¯
       POSIXå¼å®¹ç.

è¿åå¼
       æåæ¶è¿åæåå¥çåèæ°(è¥ä¸ºé¶å表示没æåå¥æ°æ®).
       é误æ¶è¿å-1,并置errno为ç¸åºå¼.
       è¥count为é¶,对äºæ®éæ件æ ä»»ä½å½±å,ä½å¯¹ç¹æ®æ件 å°äº§çä¸å¯é¢æçåæ.

é误代ç
       EBADF  fd ä¸æ¯ä¸ä¸ªåæ³çæ件æ述符æè没æ以åæ¹å¼æå¼.

       EINVAL fd ææåç对象ä¸å¯å.

       EFAULT buf ä¸å¨ç¨æ·å¯è®¿é®å°å空é´å.

       EPIPE  fd è¿æ¥å°ä¸ä¸ªç®¡é,æèå¥æ¥åç读æ¹åä¸ç«¯å·²å³é.æ¤æ¶åè¿ç¨ å°æ¥æ¶å°
              SIGPIPE ä¿¡å·;å¦ææ¤ä¿¡å·è¢«æè·,é»å¡æ忽ç¥,é£ä¹å°è¿åé误 EPIPE.

       EAGAIN 读æä½é»å¡,ä½ä½¿ç¨ O_NONBLOCK æå®äºéé»å¡å¼è¾å¥è¾åº.

       EINTR  å¨åæ°æ®ä»¥åè°ç¨è¢«ä¿¡å·ä¸æ.

       ENOSPC fd æåçæ件æå¨ç设å¤æ å¯ç¨ç©ºé´.

       EIO    å½ç¼è¾ä¸ä¸ªèç¹æ¶åçäºåºå±è¾å¥è¾åºé误.

       å¯è½åçäºå¶ä»é误,åå³äº fd æè¿æ¥ç对象.

å¼å®¹äº
       SVr4, SVID, POSIX, X/OPEN, 4.3BSD.  SVr4æ档添å äºä»¥ä¸é误代ç :
       EDEADLK, EFBIG, ENOLCK, ENOLNK, ENOSR, ENXIO, EPIPE,æèERANGE.
       对äºSVr4æå¯è½å¨åå¥é¨åæ°æ®æ¶åçä¸æ并è¿åEINTR.

åè§
       open(2), read(2), fcntl(2), close(2), lseek(2), select(2), ioctl(2),
       fsync(2), fwrite(3)


[ä¸æçç»´æ¤äºº]
       byeyear <love_my_love@263.net >

[ä¸æçææ°æ´æ°]
       2002.02.07

ãä¸å½linux论åmanæå页翻è¯è®¡åã:
       http://cmpp.linuxforum.net

è·
       æ¬é¡µé¢ä¸æçç±ä¸æ man æå页计åæä¾ã
       ä¸æ man æå页计åï¼https://github.com/man-pages-zh/manpages-zh



Linux 2.0.32                    13 January 1996                       WRITE(2)