質問

I need to write a process in C that takes a user's name via keyboard. When he presses enter, the process goes to sleep. I then need a second process to wake up upon receiving the message, saves the user's name in a file, then goes to sleep and sends a signal to the 1st program that it's done, which in turn wakes up the first program.

I know I'm supposed to use signals and message IDs, but I'm not clear on how to tackle the communication between processes.

#include <signal.h>
#include <stdio.h>

void m.signal(int x)
{
    printf("A signal has arrived.");
}

int main()
{
    signal(100, m.signal);

    while(1)
    {
        pause()
    }
}
役に立ちましたか?

解決

Interprocesscommunication can be done with Pipes. For windows see Interprocess Communications and/or Named Pipes. For Linux I'd suggest to read Inter process communication using named pipes(FIFO) in linux .

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top