summaryrefslogtreecommitdiff
path: root/src/stdio/pclose.c
blob: b39cfa15b611aa99ccb4b434f4304ab525062697 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "_stdio.h"

int pclose(FILE * stream)
{
	int status;
	pid_t child = stream->pipe_pid;
	SIGNAL_SAFE(0);

	if (child == 0) {
		/* undefined behavior */
	}

	fclose(stream);

	waitpid(child, &status, 0);
	return status;
}

/*
POSIX(2)
*/