Hi,
Is there something like windows CreateProcess in linux?
The only way to start a process in my program is to use system(); ?
Oh, do not answer to this question please :(
Any answer is appreciated
Printable View
Hi,
Is there something like windows CreateProcess in linux?
The only way to start a process in my program is to use system(); ?
Oh, do not answer to this question please :(
Any answer is appreciated
You might want to look into fork.
Thanks, But As I understood fork() creates a child process with the same memory address.
But I want to start another bin or executable file!!! Run another program?
system()
exec()
popen()
all launch executables.
Yes, But as I know all of this functions invoke a shell to do that?!!!!
Any system call?!
exec is a system call.
Port Windows IPC apps to Linux, Part 1: Processes and threads
gg
There is no system call without the shell. Indeed, as I mentioned early:
That includes stuff like cd. The shell manages process for init, the parent of all processes.Quote:
the bash shell is derived from an older unix power tool called "the C shell", and many "system commands" are actually part of the shell -- they do not have their own executables.
thanks, I got it now :)
Um, what? My init is /sbin/init, and my shell is /bin/bash -- they are two very separate processes/programs.Quote:
That includes stuff like cd. The shell manages process for init, the parent of all processes.
To add a bit here -- CreateProcess is the equivalent of a fork() then an exec() of some sort. *nix gives more flexibility in process creation than Windows does.
this can be a way. But the forked process name is not the executed application name!!! It's name is the process name that calls fork? Am I right? How to fix this?
Thanks anyone
Something to read:
Delve into UNIX process creation
Picture to look at:
Linux - Process creation
gg
You are right. Another question: If a child process terminate before the parent, after a few time the parent will be a "Zombie" process. And we know that "exec(newProcess)" family system calls, replace (so the child will terminate) the current process with newProcess.Quote:
CreateProcess is the equivalent of a fork() then an exec() of some sort. *nix gives more flexibility in process creation than Windows does.
If I use a fork and If I use exec in child process, the parent will not be a Zombie process! Why?
Thanks in advance
man waitpid:
Quote:
Originally Posted by man waitpid
Thanks, But my question is: When I use fork and the exec in child process, the parent will not be "zombie" although the child is terminated. WHY ?
(As you know, If a child terminates before parent, the parent will be "zombie")
Thanks