linux C语言 管道pipe的问题

linux C语言 管道pipe的问题,第1张

#include <stdio.h>

#include <unistd.h>

#include <string.h>

int main(int argc, const char *argv[])

{

int fd[2]

int pid

if (argc != 2)

{

printf("Usage:\n\t%s string\n", argv[0])

return 1

}

if (pipe(fd) <0)

{

printf("Unable to create pipe!\n")

return 1

}

// fork child process

pid = fork()

if (pid == 0) //child

{

close(fd[0])//close read end

write(fd[1], argv[1], strlen(argv[1]))//write message

close(fd[1])//close before exit

}

else if (pid >0) //parent

{

char buf[1024]

int len

close(fd[1])//close write end

len = read(fd[0], buf, sizeof(buf))//read from the pipe

buf[len] ='\0'

printf("<PARENT>message from child: %s\n", buf)

wait(NULL)//wait for child exit

close(fd[0])//close before exit

}

else

{

printf("Unable to fork!\n")

return 1

}

return 0

}

在设置里调一下就可以了。

至于安装路径,建议新手暂时不要想。linix的目录是有一个统一规范的,这个规范的作用是保证任何一个软件都能找到任何另一个软件、文件,一般可以运行的文件放在,bin或者,usr/bin、库文件、lib或、usr、lib、其他文件也都有自己的地方。

路径在Photoshop中是使用贝赛尔曲线所构成的一段闭合或者开放的曲线段。UNISURF,并于1972年在该公司应用。贝赛尔的方法将函数无穷逼近同集合表示结合起来,使得设计师在计算机上绘制曲线就象使用常规作图工具一样得心应手。

首先确认下,你的系统有没有安装unzip 命令包;

可以用 which unizp 若是返回一条绝对路径的话,就说明有这个命令了;

使用unzip b.zip 就可以,

若是没有unzip的命令的话,可以安装一下:

centos/redhat: yum install -y unzip

ubuntu: sudo apt-get -u unzip


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/7367054.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-04
下一篇 2023-04-04

发表评论

登录后才能评论

评论列表(0条)

保存