请问大侠们,什么是 交互方式?

在飞的特拉斯 2010-12-27 09:05:08
列出apue里面的例子:

#include "apue.h"
int main(void)
{
if(lseek(STDIN_FILENO, 0, SEEK_CUR) == -1)
print f("cannot seek\n");
else
printf("seek OK\n");
exit(0);
}

如果用 交互方式 调用此程序,则可得:
$./a.out </etc/motd
seek OK

$cat < /etc/motd | ./a.out
cannot seek

$./a.out < /var/spool/cron/FIFO
cannot seek

请帮忙分析一下
1 请问什么是交互方式
2 上面三个调用方式怎么来的结果呢

谢谢哈~
...全文
166 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yuppy 2010-12-29
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 mqdsg 的回复:]
引用 1 楼 yuppy 的回复:

交互方式 -- 〉interactively 好像就是这么翻译的..
书上写了:
If the file descriptor refers to a pipe, FIFO, or socket..

./a.out < /etc/motd 将stdin重订向到一个文件,可以seek把
./a.out < /etc/motd ! ./a.out ……
[/Quote]
就是表示通过管道作为那个a的输入
justkk 2010-12-29
  • 打赏
  • 举报
回复
apue的东西,为什么不贴到linux专区?
justkk 2010-12-29
  • 打赏
  • 举报
回复
交互方式,就是说你在shell的命令行提示符后面手工输入命令

$./a.out < /var/spool/cron/FIFO
cannot seek

FIFO是有名管道,也是不支持seek的
yui 2010-12-28
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 mqdsg 的回复:]

引用 1 楼 yuppy 的回复:

交互方式 -- 〉interactively 好像就是这么翻译的..
书上写了:
If the file descriptor refers to a pipe, FIFO, or socket..

./a.out < /etc/motd 将stdin重订向到一个文件,可以seek把
./a.out < /etc/motd ! ./a.out……
[/Quote]

“|”是管道符,表示“|”之前的命令的输出通过管道成为“|”之后的命令的输入,就像接水的软管一样
在飞的特拉斯 2010-12-27
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 yuppy 的回复:]

交互方式 -- 〉interactively 好像就是这么翻译的..
书上写了:
If the file descriptor refers to a pipe, FIFO, or socket..

./a.out < /etc/motd 将stdin重订向到一个文件,可以seek把
./a.out < /etc/motd ! ./a.out 这个是将/etc/motd作为cat的……
[/Quote]

/etc/motd | ./a.out 这句里面的 | 是什么意思呢?
yuppy 2010-12-27
  • 打赏
  • 举报
回复
交互方式 -- 〉interactively 好像就是这么翻译的..
书上写了:
If the file descriptor refers to a pipe, FIFO, or socket..

./a.out < /etc/motd 将stdin重订向到一个文件,可以seek把
./a.out < /etc/motd ! ./a.out 这个是将/etc/motd作为cat的输入,再通过什么管道作为那个a的输入,所以不可以seek

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧