Re: Passing shell control to another app
- From: Lars Rune Nøstdal <larsnostdal@xxxxxxxxx>
- Date: Wed, 27 Sep 2006 09:14:46 +0200
On Wed, 27 Sep 2006 08:53:31 +1200, Allistar wrote:
Hi all,
I have an application (developed in C++ and compiled using gcc) that
runs from a shell, to which it outputs quite a bit of information (using
printf).
Part way through the execution of the application it executes another
instance of the same app (using fork followed by execl) and then the
original instance exits. When the original instance exists the user sees
the shell prompt, yet the second instance is still running and still
outputting to the shell.
Is there a way of doing this so that control of the shell is passed to
the second instance?
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
extern char **environ;
#define MAX 50
char line[MAX];
int main(int argc, char* argv[], char* env[]){
printf("%s\n", argv[1]);
argv[1] = line;
fgets(line, MAX, stdin);
execve("/home/lars/programming/c/a", argv, env);
perror("after execve");
return 0;}
When running this:
lars@ibmr52:~/programming/c$ gcc -Wall -g a.c -o a && ./a hello
hello
Hei!
Hei!
Hva skjer?
Hva skjer?
--
Lars Rune Nøstdal
http://lars.nostdal.org/
.
- References:
- Passing shell control to another app
- From: Allistar
- Passing shell control to another app
- Prev by Date: Re: Serial port programming C++ - detect serial ports on linux
- Next by Date: Re: scope of linux in the corporates...
- Previous by thread: Re: Passing shell control to another app
- Next by thread: Re: Passing shell control to another app
- Index(es):
Relevant Pages
|