coprocess(3)

πŸŽ€ NAME πŸŽ€

coprocv, coprocvp, coprocvpe, coprocs, coprocsp β€” ok bestie, these are the girlies that execute a command in coprocessing mode. Yes we're in coprocess(3), straight out of the Linux Programmer's Manual, and she is serving πŸ’…βœ¨


🌸 SYNOPSIS 🌸

#include <execs.h>

pid_t coprocv(const char *path, char *const argv[], int pipefd[2]);
pid_t coprocve(const char *path, char *const argv[],
                           char *const envp[], int pipefd[2]);
pid_t coprocvp(const char *file, char *const argv[], int pipefd[2]);
pid_t coprocvpe(const char *file, char *const argv[],
                           char *const envp[], int pipefd[2]);

pid_t coprocs(const char *path, const char *command, int pipefd[2]);
pid_t coprocse(const char *path, const char *command,
                           char *const envp[], int pipefd[2]);
pid_t coprocsp(const char *command, int pipefd[2]);
pid_t coprocspe(const char *command, char *const envp[],
                           int pipefd[2]);

These functions are provided by libexecs. Link with -lexecs, bestie, don't forget it or you're getting nothing 🫢


πŸ’– DESCRIPTION πŸ’–

So the whole point: these functions run commands in coprocessing mode. They all do the same vibe, they just differ in the way you specify the executable file to run and its parameters.

Every single one of them:

  • defines two pipes (by pipe(2)),
  • creates a new process by fork(2),
  • redirects the standard input and standard output of that new process into the two pipes,
  • and execs a program by one of the exec(3) functions.

The way that the calling program controls both the standard input and the standard output of the called process?? Iconic, honestly. Writing to pipefd[1] feeds input to the coprocess, while the coprocess output can be retrieved from pipefd[0]. That's the whole dynamic β€” you talk in through [1], you listen out through [0]. Two-way relationship, we love to see it πŸ¦‹

Now for the family tree: coprocv, coprocve, coprocvp, coprocvpe, coprocs, coprocse, coprocsp, and coprocsp differ as they define the executable file to run and its arguments as execv, execve, execvp, execvpe, execs, execse, execsp, and execsp, respectively.

ngl bestie, that's literally how the page prints it β€” coprocsp shows up twice in that list and it lands on execsp twice at the end. I'm not touching it, no cap, I report the text exactly as she is πŸ’€

😭 BUGS 😭

Found something cursed? Bug reports should be addressed to <info@virtualsquare.org>. Tell them everything, they wanna know πŸ™ˆ


πŸ‘‘ AUTHOR πŸ‘‘

Renzo Davoli <renzo@cs.unibo.it> β€” the main character who wrote all this πŸ’œ


And that's the whole page, bestie. This one came from VirtualSquare, dated 2014-05-27, and it lives at coprocess(3) β€” go pipe something into something else, you've got this πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from