Skip to content
0:00 / 0:00

#fork#exec#pipe

Linux Systems Dev in C - fork, exec and log child process

Low Level Devel

11K subscribers • 8 videos on Hallway

YouTube
  • Recommended by 1 person: 1 in engineering communities.
  • Linked in the descriptionrockytriton/LLD

Intermediate. Assumes working knowledge.

1.7K views5 years ago1 recommendation

Systems programmingLinuxOperating systemsC

How to execute a child process in Linux using fork and exec, and redirect its output using pipes in C.

Hi and welcome to the low level devel channel. In this linux systems programming video series, I'm going to be going into detail on some of the shared functions that I create for some of the other video serieses. Many of these are going to be used in the linux distribution from scratch series, but I'm taking some of these functions out into individual units to make the videos smaller and usable by other projects. In this video I'm going to show how to execute a child process, use the pipe syscall to read its stdout and stderr and write those to the parent process's stdout as well as an optional log file. Discord: discord.gg/fyFYABCVMX Github: github.com/rockytriton/LLD Reddit: reddit.com/r/LowLevelDevel Donate (Paypal/Venmo): rockytriton75@gmail.com

Why it's here

1 person recommends this

What people say. Recommended as a clear tutorial on using POSIX system calls in C to manage and log child processes.

u/Rockytritonin r/C_Programming • Recommends

Using fork, exec and pipe to log a child process

u/Rockytritonin r/C_Programming • Mentions

On “freopen("stderr.txt", "rb+,type=mem", stderr);”

Maybe this video will help, it goes over how to fork, exec and use dup2 to redirect output to a file: [video . Also it's important to note that you can redirect stdout and stderr to a file, but if you want to read user input you need to use stdin.