elks-enhanced
public
Read
Owner: themaster
Branch: master
Commits: 6893
Updated: 2026-04-19 00:15
Git CLI clone URL
git clone https://www.xt-emporium.com/git/elks-enhanced.git
Fullscreen desktop URL
Code
Commits
History
Branches
Bug Reports
Discussions
Compare
Settings
elks-enhanced
/
libc
/
misc
/
popen.c
File editor
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/wait.h> #include <paths.h> FILE *popen(const char *command, const char *rw) { int pipe_fd[2]; int pid, reading; if (command == NULL || pipe(pipe_fd) < 0) return NULL; reading = (rw[0] == 'r'); pid = vfork(); if (pid < 0) { close(pipe_fd[0]); close(pipe_fd[1]); return NULL; } if (pid == 0) { close(pipe_fd[!reading]); close(reading); if (pipe_fd[reading] != reading) { dup2(pipe_fd[reading], reading); close(pipe_fd[reading]); } execl(_PATH_BSHELL, "sh", "-c", command, (char*)0); _exit(255); } close(pipe_fd[reading]); return fdopen(pipe_fd[!reading], rw); } int pclose(FILE *fd) { int waitstat; if (fclose(fd) != 0) return EOF; return wait(&waitstat); }
Commit message
This repository is read-only for this account.
Repository snapshot
Current branch
master
Visibility
public
Your access
Read
Remote
Configured
File activity
View file history