04-27-2010
Quote:
Hello World!
I am writing code in C++ which have to launch another application X using exec().
exec() doesn't as much launch another application as much as replace the same process with a different one, fyi.
10 More Discussions You Might Find Interesting
1. Programming
Hello!
I am working on a server where I should have 4 (resident)processes, one of them being "the father" of the others, so I do 3 forks. The problem that I have is that I do an accept (for sockets) in the "father" process and I want to transmit the job to one of the processes "child" with... (3 Replies)
Discussion started by: driki
3 Replies
2. UNIX for Dummies Questions & Answers
Hi!
Can someone explain me exactly this technique? Why a process (PARENT) creates a copy of itself with FORK (CHILD)? What's the reason of this behaviour? Sorry, but I cannot understand the logic behind it.
Thanks. (4 Replies)
Discussion started by: marshmallow
4 Replies
3. Programming
On my *nix box, I have a telegram program.
When I go like
tel person "la\nla\nla\n"
the person sees
"la\nla\nla\n"
However, when I have a program that forks and execs tel like:
pid = fork();
if (pid < 0) {
perror("fork failed");
exit(EXIT_FAILURE);
}
if (pid == 0) {... (7 Replies)
Discussion started by: frequency8
7 Replies
4. Solaris
Hi,
I need to find/implement an application that FTPs (puts) all new files in a certain directory to an external storage unit. This application should check for new files every 10 seconds (leaving the FTP connection open in between the 10 seconds).
The easiest way would be if there are... (2 Replies)
Discussion started by: KittyJ
2 Replies
5. Shell Programming and Scripting
I need to ssh to a remote server and run my script there. This is my script.
$ssh = "ssh username@host";
$cmd = "$ssh 'cd <my dir> && < sudo Run_exe>'";
my $pid = fork;
if ($pid == 0){
exec $cmd;
}
When I run this I get:
pccons_getchar: got r == 0 (1 Reply)
Discussion started by: looza
1 Replies
6. Programming
Consider the following code..
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include <stdio.h>
#include <sys/wait.h>
#include <stdlib.h>
int main()
{
pid_t childpid;
int retval;
int status;
childpid = fork();
if(childpid >= 0)
{
... (4 Replies)
Discussion started by: lipun4u
4 Replies
7. Programming
Hi All,
In my program i am handling SIGHUP signal. In the handler i fork and then exec on child process same binary file which is running. Parent process will die after 10 mins.
Now my child process which was exec with same binary file is not receiving SIGHUP signal. Below is the progran code:... (6 Replies)
Discussion started by: sushil_shalin
6 Replies
8. Programming
Hello everybody.I want to make clear that i am not going to ask from anybody to build my asignement but i have a big problem. I can't seem to find anywhere ONE good example on C about what i am trying to do:wall:.I think it is simple. All i ask is one example, even a link is fine.
So, i want to... (1 Reply)
Discussion started by: Cuervo
1 Replies
9. UNIX for Dummies Questions & Answers
What is is difference between 'fork with exec' and 'fork without exec'?
How both are related? (1 Reply)
Discussion started by: kkalyan
1 Replies
10. UNIX for Beginners Questions & Answers
Hello... And thanks in advance for any help anyone can offer me on my question! I've been doing a lot of reading to try and find my answer... But I haven't had any luck
What I'm trying to understand is where a child process inherits global environment variables from? I understand the exec()... (2 Replies)
Discussion started by: bodisha
2 Replies
system(3S) system(3S)
NAME
system() - issue a shell command
SYNOPSIS
DESCRIPTION
executes the command specified by the string pointed to by command. The environment of the executed command is as if a child process were
created using (see fork(2)), and the child process invoked the sh-posix(1) utility via a call to (see exec(2)) as follows:
ignores the and signals, and blocks the signal, while waiting for the command to terminate. If this might cause the application to miss a
signal that would have killed it, the application should examine the return value from and take whatever action is appropriate to the
application if the command terminated due to receipt of a signal.
does not affect the termination status of any child of the calling processes other than the process or processes it itself creates.
does not return until the child process has terminated.
APPLICATION USAGE
If the return value of is not -1, its value can be decoded through the use of the macros described in For convenience, these macros are
also provided in
Note that, while must ignore and and block while waiting for the child to terminate, the handling of signals in the executed command is as
specified by fork(2) and exec(2). For example, if is being caught or is set to when is called, the child is started with handling set to
Ignoring and in the parent process prevents coordination problems (such as two processes reading from the same terminal) when the executed
command ignores or catches one of the signals.
RETURN VALUE
If command is null, returns non-zero.
If command is not null, returns the termination status of the command language interpreter in the format specified by wait(2). The termi-
nation status of the command language interpreter is as specified for sh-posix(1), except that if some error prevents the command language
interpreter from executing after the child process is created, the return value from is as if the command language interpreter had termi-
nated using If a child process cannot be created, or if the termination status for the command language interpreter cannot be obtained,
returns -1 and sets to indicate the error.
DIAGNOSTICS
forks to create a child process which, in turn, in order to execute string. If the fork fails, returns -1 and sets If the exec fails,
returns the status value returned by (see wait(2)) for a process that terminates with a call of
ERRORS
If errors are encountered, sets values as described by fork(2).
FILES
SEE ALSO
sh(1), fork(2), exec(2), wait(2), thread_safety(5).
STANDARDS CONFORMANCE
system(3S)