Skip to content

Tag: system-calls

dup2 paramater order confusion

I have written this simple program: What i want is, redirect the output of ls – l to a file called “theFile.txt”. The code works as i expect. What confuses me here is the order of dup2 parameters. I believe that correct order should be dup2(1, fd) – considering fd as the newFD and 1 as…

Intermittent segmentation faults in main after fork

I’m taking a class on how to learn programming multi process programs on linux on university. I’m still very green and trying my best to learn, so any thing you might see that is wrong would be welcome. I have a problem that asks me to iterate an array, one half on main process, the other half on …