Re: how is "exec" executed by a shell?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 01/07/2005 10:15 AM, Mandeep Sandhu wrote:
> $ exec man
> 
> The shell closed!
> 
> $ exec man &
> [1] 10618
> $ What manual page do you want?
>  
> [1]+  Exit 1                  exec man
> $
> 
> The man page of exec says....
> "If  command is specified, it replaces the shell."

Yes, that's exactly what "exec man" did, replace the shell with man. man can't 
live without a shell, thus it exited.

> But does'nt the shell "wait" for whatever command is given to it
> to complete???....little confused here. Moreover

No, as you stated above, the shell is replaced by the command specified.

>From the exec man page:

If exec is specified with command, it shall replace the shell with command  
without  creating  a new  process.

> $ exec exit
> bash: exec: exit: not found
> 
> did not work! is'nt "exit" also a command?

The command "exit" is a shell builtin.

Correct me if I'm wrong somewhere.

Thanks, Tobias

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux