fucalerro / 42-minishell

1 stars 0 forks source link

standalone vs piped cmd #29

Closed Lu-ni closed 6 months ago

Lu-ni commented 7 months ago

Command in a Pipeline: When a command is part of a pipeline (connected by pipes |), it runs in a subshell. This subshell is effectively created through a process similar to forking. Each command in the pipeline runs in its own subshell, isolated from the parent shell and other subshells in the pipeline.

Standalone Command: When a command is run standalone (not part of a pipeline), it typically runs in the current shell process, especially if it's a shell builtin like cd. For builtins, no fork is required since they are executed directly by the shell. For external commands (like most Unix commands such as ls, grep, etc.), the shell forks a new process to execute the command.

for example: cd | echo ola does not cd in the shell because the cd is run in a fork.

Lu-ni commented 7 months ago

We need to tag "piped cmd" and run then in a fork if they're flagged

Lu-ni commented 7 months ago

This issue mostly stand for builtin cmd