![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Remote Exec | TheEngineer | AIX | 1 | 05-12-2006 04:50 AM |
| find and exec | big123456 | UNIX for Advanced & Expert Users | 2 | 01-02-2006 12:10 PM |
| exec comand | mkan | UNIX for Dummies Questions & Answers | 5 | 09-09-2005 03:24 AM |
| using the -exec command | moxxx68 | UNIX for Dummies Questions & Answers | 0 | 04-13-2004 02:51 PM |
| exec | Nisha | Shell Programming and Scripting | 1 | 09-23-2002 05:56 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
exec
I have read that exec "replaces the current process with a new one".
So I did $ exec ls and after this executed, my shell disappeared. I am assuming that my shell had PID xyz, and when I did exec ls, this ls got pid xyz, and when it terminated, there was no more shell process running, and so it terminated. Is this correct?? Second question, say I am running a Java program, and I do a system call, of exec ls. Does this mean that the Java process will be replaced by ls? Thanks in advance. |
|
||||
|
for exec ls,
the child process ls - will replace the address space of the parent process which is the interpretor, after exec effectively there is only one address space in execution previously it was the parent ( shell ) and now its the child ( ls ) After execution of ls, like any other binary - ls also terminates. Once it terminates the session also closes as there is no effective program running |
|
||||
|
Quote:
![]() In UNIX a process is a running entity managed by the operating system and a program is a file on disk. In MS-DOS, Windows, OS/2, classic MacOS the only way to create a process was to run a program and the OS would create a new process to run the program. In UNIX they are two separate activities (a) create a new process, ie, fork and (b) replace the current running program with a new program, eg exec. So in Windows what would be "CreateProcess" is in UNIX a fork followed by exec. Although 99% of the time we want to fork/exec there are a few occasions where replacing the current program is the thing to do. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|