相关疑难解决方法(0)

两个进程如何在没有 pipe() 的情况下相互通信?

鉴于此代码:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>

#define BUF_SIZE 256

int main()
{
    int fd1[2];
    int fd2[2];

    ssize_t numRead = -1;

    // remark : working under the assumption that the messages are of equal length

    const char* messageOne = "Hello world , I'm child number 1\n";
    const char* messageTwo = "Hello world , I'm child number 2\n";

    const unsigned int commLen = strlen(messageOne) + 1;

    char buf[BUF_SIZE];

    if (pipe(fd1) == -1)
    {
        printf("Error opening pipe 1!\n"); …
Run Code Online (Sandbox Code Playgroud)

c linux pipe named-pipes

0
推荐指数
1
解决办法
2448
查看次数

标签 统计

c ×1

linux ×1

named-pipes ×1

pipe ×1