Linux FIFO代码问题 - Linux/Unix社区 / 程序开发区
/*speak.c*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define FIFO_NAME "american_maid"
int main(void)
{
char s[300];
int num, fd;
mknod(FIFO_NAME, S_IFIFO | 0666, 0);
printf("waiting for readers...\n");
fd = open(FIFO_NAME, O_WRONLY);
printf("got a reader--type some stuff\n");
while (gets(s), !feof(stdin)) {
if ((num = write(fd, s, strlen(s))) == -1)
perror("write");
else
printf("speak: wrote %d bytes\n", num);
}
return 0;
}
/*tick.c*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define FIFO_NAME "american_maid"
int main(void)
{
char s[300];
int num, fd;
mknod(FIFO_NAME, S_IFIFO | 0666, 0);
printf("waiting for writers...\n");
fd = open(FIFO_NAME, O_RDONLY);
printf("got a writer\n");
do {
if ((num = read(fd, s, 300)) == -1)
perror("read");
else {
s[num] = '\0';
printf("tick: read %d bytes: \"%s\"\n&
相关问答:
咨询QQ:269562808
bzip2recover
功能说明:用来修复损坏的.bz2文件。
语法:bzip2recover[.bz2压缩文件]
补充说明:bzip2是以区块的方式来压缩文件,每个区块视为独立的单位。因此,当某一区
块损坏时,便可利 ......
每次man的时候都是英文版的, 不知道怎么apt-get中文版的man阿?
漫漫找
难找啊,不过英文的也挺好啊
同感啊。。。
可以直接看英文的,不懂的查字典
那英文的那个地址在哪儿阿
看看/usr/share/man 和 / ......
tomcat自动重启脚本:
ps -ef | grep tomcat | grep -v grep | sed 's/ [ ]*/:/g' | cut -d: -f3 | kill -9
./startup
请问上面的脚本能不能帮我解释下,谢谢
学习~
你的意思不是太明白,是想自己写 ......
昨天为了解决win与linux的乱码问题,在/etc的sysconfig/i18n里面添加了支持中文的代码,结果变成中文后桌面只能显示背景了,现在几乎只能用终端和上网了,文件夹都无法正常显示(看不到里面的东西),我没有备份系统 ......