Skip to content

Commit

Permalink
pipe: add ability to restore both ends of inhereted pipes
Browse files Browse the repository at this point in the history
When we restore an inhereted pipe, we have only one end and we
don't know whether it's write or read one. So we need to call
reopen_pipe each time.

Signed-off-by: Andrey Vagin <[email protected]>
Signed-off-by: Pavel Emelyanov <[email protected]>
  • Loading branch information
avagin authored and xemul committed Jul 15, 2015
1 parent 98c8e44 commit d6f39d7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pipes.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,15 @@ static int open_pipe(struct file_desc *d)
int pfd[2];
int sock;

if (inherited_fd(d, &tmp))
return tmp;

pi = container_of(d, struct pipe_info, d);
pr_info("\t\tCreating pipe pipe_id=%#x id=%#x\n", pi->pe->pipe_id, pi->pe->id);
if (inherited_fd(d, &tmp)) {
if (tmp < 0)
return tmp;

pi->reopen = 1;
goto out;
}

if (!pi->create)
return recv_pipe_fd(pi);
Expand Down Expand Up @@ -357,6 +361,7 @@ static int open_pipe(struct file_desc *d)
close(pfd[!(pi->pe->flags & O_WRONLY)]);
tmp = pfd[pi->pe->flags & O_WRONLY];

out:
if (pi->reopen)
tmp = reopen_pipe(tmp, pi->pe->flags);

Expand Down

0 comments on commit d6f39d7

Please sign in to comment.