filter_create_fd(3)

πŸ’– filter_create_fd β€” bestie edition πŸ’–

okay so this one is from util/filter.h (the ClearSilver crew, we love them), and it's literally the "make a whole sub process and hand me pipes to its insides" function. group-chat energy only, but the facts stay facts. 🫢


✨ NAME ✨

filter_create_fd β€” spin up a sub process and hand back whichever pipes you asked for πŸ’…


🌸 SYNOPSIS 🌸

#include <util/filter.h>

NEOERR *filter_create_fd(const char *cmd, int *fdin, int *fdout, int *fderr,
                         pid_t *pid);

πŸŽ€ ARGUMENTS πŸŽ€

  • cmd β€” the sub command you wanna run. it gets executed with /bin/sh -c, no cap.
  • fdin β€” pointer where the stdin pipe comes back, or NULL if you don't want the stdin pipe, bestie.
  • fdout β€” pointer where the stdout pipe comes back, or NULL if you don't want the stdout pipe.
  • fderr β€” pointer where the stderr pipe comes back, or NULL if you don't want the stderr pipe.

πŸ¦‹ DESCRIPTION πŸ¦‹

filter_create_fd and filter_create_fp are what popen

been: a mechanism to create sub processes and have pipes to all their input/output. the concept was taken from mutt, though python has something similar with popen3/popen4. (iykyk 🐍)

you control which pipes the function returns by the fdin/fdout/fderr arguments. a NULL value means "don't create a pipe", a pointer to an int will cause the pipes to be created and the value of the file descriptor stored in the int. 🌈

not me reminding you: you will have to close(2) the file descriptors yourself. nobody's gonna do it for you, main character. πŸ’€

πŸ‘‘ RETURN VALUE πŸ‘‘

  • fdin β€” the stdin file descriptor of the sub process
  • fdout β€” the stdout file descriptor of the sub process
  • fderr β€” the stderr file descriptor of the sub process
  • pid β€” the pid of the sub process

πŸ”₯ SEE ALSO πŸ”₯

filter_wait(3), filter_create_fp(3), filter_create_fd


that's the whole vibe, bestie β€” ClearSilver, dated 12 July 2007, and honestly it ate. go close your file descriptors. periodt. πŸ’–βœ¨πŸŽ€πŸ¦‹