Question

I'm coding a small shell that must execute my commands that I parse.

f is a char** like this: [ls][-la] p is the same, used like this: [wc] So I tried to pipe ls -la in wc. My probleme is that when I execute "ls -la | wc && date", which works well for the pipe, my minishell get closed and it doesn't execute "date". I used the wait function to wait for it to finish but doesn't do anything. Looks like it's stuck and exit just after the 2nd execvp.

My arrays ends well by NULL. ls -la | wc is well executed but I get back to bash after this. I've tried with execlp and execl but I think this is not the probleme considering that I need options of my first argument (ls + -la). Could you help me please ? Thanks in advance :)

Was it helpful?

Solution

All forms of exec never return; they replace the currently running image with the indicated executable. The key word here is "replace".

The only circumstance in which the statement following a call to exec* gets executed is if the exec fails (for example, if it cannot find the executable).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top