When UNIX creates a new process, for example when you login:
1. the kernel has to take an existing process and then copy all of it into another part of memory.
2. Next it creates kernel entries to support the new process.
3. Finally it gives control of the cpu to user space in the new process
4. (optional) load an executable image into the process overwriting the old process memory. exec() does this, fork() does not do this.
Steps 1-3 is what fork() does, it is commonly called spawning a new process. Step 4 is performed by exec(). They are very different. So when you type
You create a child process using 1,2, 3, then you exec() awk, step 4.
Where the problems come in:
1. all modern UNIX systems also support posix_spawn(), which does not copy all of memory. Its function is to do a "lightweight" version of fork().
2. Linux has something like posix_spawn() called clone().
3. Some other oddball systems also have a spawn() system call which acts more or less like fork()/exec().
An example of fork()/exec() is the C system() function.
So in effect you can say:
fork() spawns a new process.
posix_spawn() spawns a new process.
clone() spawns a new process.
system() spawns a new process.
So, the word spawn does not have to refer to a specific UNIX function, just what happens to make a new process.
These 2 Users Gave Thanks to jim mcnamara For This Post:
Hi,
I am writing a script to automate installation of java in shell script.
#!/bin/sh
#!/usr/bin/expect
ls -la | grep jdk* | rpm -ivh ./jdk*.rpm
alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_71/bin/java 2
spawn alternatives --config java
expect "Enter to keep the current... (5 Replies)
Hi all,
I want to run the following command from my main prompt :
# spawn bash
but I get the following error:
spawn: Command not found.
For this to work , I first have to go into expect.
#expect
expect1.1>spawn bash
spawn bash
564
expect1.2>
Is there any way I can skip the... (2 Replies)
Hi,
I have a script that run every 10 minutes, from a specific timeframe of the day, for example 0500 - 1900.
The script is some sort of checker script for an application log file and check for errors and email us if there is error/s reported in the log.
At the moment, I schedule it... (1 Reply)
Hi,
I have a problem with the spawn execution with expect.. i have done the code for expect in a separate file and i am calling the this execution from the bash script.. as given below..
-bash-4.1$ cat main.sh
#!/usr/bin/bash
./spawn.exp
==========================
-bash-4.1$ cat... (2 Replies)
Hi
I am trying to spawn an snmptrap from python but i keep getting the following error
Invalid version specified after -v flag: 2c -c public 192.168.2.162 SNMPv2-SMI::enterprises.3.1.1
here is the python code i am using
from subprocess import Popen
Popen()
When i test the same... (0 Replies)
Hello Everyone:
I have the following code
int main()
{
system("/usr/OtherUser/bin/runX");
return 0;
}
runX must be executed with privileges from another user, how could I do that? I know the password for such user.
Thanks in advance (8 Replies)
I need to run the spawn command but when I typed it in, I got
"ksh: spawn: not found".
So, I downloaded spawn-fcgi but it required to be compiled first. The compile failed when I tried it. I need a copy that's ready to be used.
Unix system info:
OS: Sun Solaris 2.8
Shell: ksh
Does... (4 Replies)
Hi,
I'm very new to UNIX.
I need to FTP a file to a remote host. It happens through a port 2222.I need to automate the process as the SCP command prompts for a password.
1) The regular ftp, tells me that the connection is refused
2) The sftp login@remotehost
gives me... (0 Replies)