DRAFT lib: Add missing pipe prototype.

* include/unistd.h (pipe: New prototype.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2022-11-01 19:52:53 +01:00
parent 0e13782f0e
commit a76d1f2c84
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
3 changed files with 6 additions and 4 deletions

View File

@ -82,6 +82,7 @@ int getpgid (pid_t pid);
int isatty (int fd);
int link (char const *old_name, char const *new_name);
off_t lseek (int fd, off_t offset, int whence);
int pipe (int filedes[2]);
ssize_t read (int fd, void *buffer, size_t size);
ssize_t readlink (char const *file_name, char *buffer, size_t size);
#if __SBRK_CHAR_PTRDIFF

View File

@ -26,6 +26,8 @@
#include <sys/types.h>
#include <sys/wait.h>
extern int *__ungetc_buf;
int
pclose (FILE *stream)
{

View File

@ -23,6 +23,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
@ -34,8 +35,6 @@
#define SHELL_COMMAND_NAME "sh"
#endif
extern int *__ungetc_buf;
FILE *
popen (char const *command, char const *mode)
{
@ -61,7 +60,7 @@ popen (char const *command, char const *mode)
// child
int dup = (*mode == 'w'
? dup2 (pipedes[STDIN], STDIN)
: dup2 (pipedes[STDOUT], STDOUT))
: dup2 (pipedes[STDOUT], STDOUT));
if (dup < 0)
_exit (127);
@ -109,6 +108,6 @@ popen (char const *command, char const *mode)
// XXX misuse ungetc buffer for PID
// XXX TODO: make proper FILE struct
__ungetc_init ();
__ungetc_set (filedes, pidchild);
__ungetc_set (filedes, pid);
return stream;
}