《Advanced Programming in the UNIX Environment, 3rd Edition》的原文摘录

  • Parent and the child share a file table entry for every open descriptor. (查看原文)
    LionHeart 2011-09-24 13:51:27
    —— 引自章节:Ch 8 Process Control
  • 大多数UNIX调试程序都使用core文件以检查进程终止时的状态。 (查看原文)
    timebug 1回复 6赞 2011-10-30 13:28:33
    —— 引自第234页
  • 将进程的信号屏蔽字设置为由sigmask指向的值。在捕捉到一个信号或发生了一个会终止该进程的信号之前,该进程被挂起。如果捕捉到一个信号而且从该信号处理程序返回,则sigsuspend返回,并且将该进程的信号屏蔽字设置为调用sigsuspend之前的值。 (查看原文)
    timebug 5回复 3赞 2011-11-02 08:25:54
    —— 引自第269页
  • 与应用程序使用文件描述符(fd)访问文件一样,访问套接字也需要使用套接字描述符,其在unix系统中是用文件描述符实现的。 在AF_INET通信域中套接字SOCK_STREAM的默认协议是TCP,SOCK_DGRAM的默认协议是UDP。 不同处理器架构支持不同的字节序,小端(little-endian)freebsd linux on intel pentium,大端(big-endian)mac os on power pc solaris on sun sparc,有些处理器可以配置大端和小端,更加混乱。 TCP/IP 采用大端字节序。对于TCP/IP,地址是使用网络字节序来表示,所以应用程序有时候需要在处理器的字节序和网络字节序之间转换。 uint32_t htonl(uint32_t hostint32); uint16_t htons(uint16_t hostint16); uint32_t ntohl(uint32_t netint32); uint16_t ntohsl(uint16_t netint16); h 代表host n 代表network l 代表 long s 代表 short (查看原文)
    [已注销] 2012-03-11 14:50:47
    —— 引自第440页
  • 由open返回的文件描述符一定是最小的未用描述符数值。这一点被某些应用程序用来在标准输入,标准输出或标准错误输出上打开新的文件。 (查看原文)
    卧草泥马 2012-08-30 22:34:51
    —— 引自第49页
  • 其中,atexit的参数是一个函数地址,当调用此函数时无需向它传送任何参数,也不期望它返回一个值。exit以登记这些函数的相反顺序调用它们。同一函数如若登记多次,则也被调用多次。 (查看原文)
    DexterL 2012-12-05 11:08:41
    —— 引自第124页
  • 如果 name 不是一个合适的常量,则所有这三个函数都会返回 -1,并将 errno 设置为 EINVAL。 (查看原文)
    jasonz 2013-07-28 23:48:02
    —— 引自第33页
  • Although sbrk can expand or contract the memory of a process, most versions of malloc and free never decrease their memory size. The space that we free is available for a later allocation, but the freed space is not usually returned to the kernel; that space is kept in the malloc pool. (查看原文)
    [已注销] 3回复 2014-06-18 20:41:53
    —— 引自章节:Process Environment
  • Pipes have two limitations. 1. Historically, they have been half duplex (i.e., data flows in only one direction). Some systems now provide full-duplex pipes, but for maximum portability, we should never assume that this is the case. 2. Pipes can be used only between processes that have a common ancestor. Normally, a pipe is created by a process, that process calls fork, and the pipe is used between the parent and the child. (查看原文)
    jeff 2015-04-02 21:25:35
    —— 引自第496页
  • 标准I/O库提供缓冲的目的是尽可能的减少使用read和write调用的次数。(见图3-6, 其中显示了在不同缓冲区长度情况下,执行I/O所需的CPU时间量)。它也对每个I/O流自动地进行缓冲管理,从而避免了应用程序需要考虑这一点带来的麻烦。遗憾的是,标准I/O库最令人迷惑的也是它的缓冲。 本章描述的函数经常被称为不带缓冲的I/O(unbufferd I/O, 与将在第五章中说明的标准I/O函数对照)。术语不带缓冲指的每个read和write都调用内核中的一个系统调用。P61 第3章 (查看原文)
    knightley 2017-01-16 16:26:43
    —— 引自第116页
  • In most job-control shells, this function is called after a fork to have the parent set the process group ID of the child, and to have the child set its own process group ID. One of these calls is redundant, but by doing both, we are guaranteed that the child is placed into its own process group before either process assumes that this has happened. If we didn't do this, we would have a race condition, since the child's process group membership would depend on which process executes first. (查看原文)
    Jake 2020-12-09 15:07:13
    —— 引自第294页