Added pipedata struct
This commit is contained in:
@@ -6,19 +6,32 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include "pipedata.h"
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
int p1[2];
|
||||||
|
pipe(p1);
|
||||||
|
|
||||||
pid_t parent = getpid();
|
pid_t parent = getpid();
|
||||||
pid_t child = fork();
|
pid_t child = fork();
|
||||||
|
|
||||||
if (child > 0) // parent
|
if (child > 0) // parent
|
||||||
{
|
{
|
||||||
|
close(p1[0]); // read
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
close(p1[1]); // write
|
||||||
}
|
}
|
||||||
else // child
|
else // child
|
||||||
{
|
{
|
||||||
|
close(p1[1]); // write
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
close(p1[0]); // read
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
11
src/pipedata.h
Normal file
11
src/pipedata.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#ifndef _PIPDATA_H
|
||||||
|
#define _PIPDATA_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
struct pipestruct
|
||||||
|
{
|
||||||
|
std::string s;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _PIPDATA_H
|
||||||
Reference in New Issue
Block a user