popen_nosh(3)
π NAME
okay so bestie, meet popen_nosh, pclose_nosh, popen_execs, pclose_execs β the whole girl gang from Linux Programmer's Manual, section 3, and their thing is: pipe a stream to or from a process without using a shell. no shell, no drama, no sh -c jumping in uninvited π
β¨ SYNOPSIS
#include <stdio.h>
#include <execs.h>
FILE *popen_nosh(const char *command, const char *type);
int pclose_nosh(FILE *stream);
FILE *popen_execsp(const char *command, const char *type);
int pclose_execsp(FILE *stream);
FILE *popen_execs(const char *path,const char *command, const char
*type);
int pclose_execs(FILE *stream);
These functions are provided by libexecs. Link with -lexecs. yes literally just that, don't forget the flag or you'll be crying at the linker π«Ά
πΈ DESCRIPTION
okay so here's the tea β
popen_nosh, popen_execsp and pclose_nosh are almost drop in replacement for popen(3) and pclose(3) provided by the libc. almost β key word, bestie.
popen_nosh and popen_execsp are synonyms: they parse the command string and run the command directly, without using a shell. no middleman, no shell, just vibes and exec β¨
Command arguments in args are delimited by space characters (blank, tabs or new lines). so like, spaces, tabs, newlines β all of them are the divider bestie π«
Single or double quotes can be used to delimitate command arguments including spaces, and a non quoted backslash (\) is the escape character to protect the next char. so quote it up if your arg has spaces in it, or backslash-escape the next char to keep it safe π
The executable file is sought using the PATH environment variable as explained for execlp(3). yes, PATH, that same one, go read execlp(3) if you want the full lore π
pclose_nosh closes a stream opened by popen_nosh. that's it, that's the job π«‘
popen_execs requires the path of the executable to be specified as its first parameter so it does not use the PATH environment variable. you bring the path yourself, main character energy π
pclose_execs closes a stream opened by popen_execs. matching set, we love a matching set π
π RETURN VALUE
These functions have the same return values of popen(3) and pclose(3). same numbers, same energy, no surprises. go check those pages for the exact deets, i'm not gonna lie to you bestie π
ngl if you skipped the -lexecs link flag you're gonna have a bad time, and that's on periodt π
and that's a wrap, babe β this little love letter is brought to you by VirtualSquare, dated 2014-05-27, filed under popen_nosh(3). go forth and pipe responsibly π¦π
π¦ where this page comes from
- debian bookworm: libexecs-dev 1.3-2 Β· LGPL-2.1-or-later
- debian trixie: libexecs-dev 1.4-2+b2 Β· LGPL-2.1-or-later
- ubuntu jammy: libexecs-dev 1.3-1 Β· LGPL-2.1-or-later
- ubuntu noble: libexecs-dev 1.4-2build1 Β· LGPL-2.1-or-later
- ubuntu questing: libexecs-dev 1.4-2build1
- ubuntu resolute: libexecs-dev 1.4-2build2 Β· LGPL-2.1-or-later
- ubuntu stonking: libexecs-dev 1.4-2build2 Β· LGPL-2.1-or-later
- Copyright (C) 2014 Renzo Davoli. University of Bologna. <renzo@cs.unibo.it>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms