hello, i am trying to emulate execution of multiple commands like what the shell does. i have some concepts in mind and i hope u guys can correct me if im wrong.
example command: ls -a | sort
Find out if any piping is needed by looping the string to find "|"
Set pipeFlag as 1
Create Pipe // pipe(p)
If Under Parent
If pipeFlag then
Connect Upstream to pipe (dup2(p)
Execute command ls -a
Wait for child to finish....
If Pipeflag then
Connect downstream to pipe(dup2(p)
execute other commands normally
i would like some advice on how i could split up the string for the commands. appreciate any help. thanks.