[技术学习]UNIX环境高级编程(APUE)学习记录

运行环境:
Linux thinkhy-laptop 2.6.22-14-generic #1 SMP Tue Feb 12 07:42:25 UTC 2008 i686 GNU/Linux
线程模型:posix
gcc 版本 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
 

1. p375 14.4 STREAMS

sys/conf.h在Linux 中缺失,实际上程序14-9忽略这个头文件也可以运行。
=================================================================
14-9 运行结果:
   who  thinkhy  tty7         2009-01-07 18:09 (:0)
           thinkhy  pts/0        2009-01-07 21:39 (:0.0)

  thinkhy@thinkhy-laptop:~/work/apue.2e/advio$ sudo ./14-9 /dev/pts/0
                                                                                        /dev/pts/0 is not a stream

 thinkhy@thinkhy-laptop:~/work/apue.2e/advio$ sudo ./14-9 /dev/tty7
                                                                                      /dev/tty7 is not a stream
tty7与pts/0都不是流设备,怪了!

==================================================================
14-10运行结果:
thinkhy@thinkhy-laptop:~/work/apue.2e/advio$ sudo echo hello, world|./catgetmsg
getmsg error: Function not implemented    Linux 2.6.22-14-generic居然没有实现getmsg 书中是在Solaris上演示的。

==========================================================
14.4节暂时未看懂,先略过。
什么叫作流?

 

============================================================================

CSAPP中文版   P743 check_clients函数 21 注释: EOF detected.,remove descriptor from pool

问题是什么时候会出现EOF?  知道了,原来是客户端主动关闭它的连接端,服务端就可以检测到EOF。

 

=============================================================

APUE14.8节实现了两个函数:readn和writen,以满足对FIFO、终端、网络和STREAM设备的读写。

这些设备都满足这两个性质:

      1> 一次read操作所返回的数据可能少于所要求的数据。

      2> 一次write操作的返回值也可能少于指定输出的字节数。

 

390页的这两段代码看似不错,实际上都有问题。

CSAPP11.4.1也实现两个类似的函数:rio_readn和rio_writen,两者的比较在另一篇文章。

====================================================
14-12表述不对!

14-12.c
thinkhy@thinkhy-laptop:~/work/apue.2e/advio$ time ./mcopy /winD/film/kongfuxiongmao.rmvb k.rm

real    0m32.683s
user    0m0.228s
sys     0m1.160s

thinkhy@thinkhy-laptop:~/work/apue.2e/advio$ time ./read </winD/film/kongfuxiongmao.rmvb >test.rm

real    0m27.864s
user    0m0.036s
sys     0m2.276s
thinkhy@thinkhy-laptop:~/work/apue.2e/advio$ time ./mcopy /winD/film/kongfuxiongmao.rmvb test.rm

real    0m31.267s
user    0m0.268s
sys     0m1.000s
==========================================================
 struct timeval {
       long tv_sec;    /* seconds */
     long tv_usec;  /* microseconds */
 }
===========================================================
p703 Ex14.8 C-14.c  v
Linux 2.6.22          65536

============================================================
习题14.3有点疑惑
============================================================
O_RDONLY定义在头文件fcntl.h中
============================================================
遇到一个调试错误:
Program received signal SIGSEGV, Segmentation fault.
0x0804871b in main (argc=1, argv=Cannot access memory at address 0xb9a352e0
) at ex14-9.c:7
7       #include <sys/stat.h>

================================================================================
14.4 STREAMS 没看懂
=========================================================
上水木问怎样让grep 的第二个参数支持正则表达式
grep xx dir   dir支持正则表达式

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值