Forking wiht zvterm



In the following code I'm unable to get a Python interpreter running
in a zvt widget after a fork. Instead the Pyhton interpreter runs in
the terminal where the initial application was started and no windows
appears.

Looking at the childed process with 'ps axf' shows me that:

30694 ?        S      0:03 gnome-terminal
30695 ?        S      0:00  \_ gnome-pty-helper
30696 pts/0    S      0:00  \_ bash
 5730 pts/0    S      0:00      \_ [python]
 5731 pts/0    Z      0:00          \_ [gnome-pty-helpe <defunct>]
 5732 pts/2    S      0:00          \_ [python]


Any idea about the problem ?

Thanks

Hilaire

------------------------ dummy.c --------------------
#include <unistd.h>
#include <stdlib.h>
#include <config.h>
#include <gnome.h>
#include <zvt/zvtterm.h>

extern char      **environ;             
static char      **env_copy, **p;
static int       i;

int main (int argc, char * args[])
{

GtkWidget *win, *term;

 /* set up environment */
 for (p = environ; *p; p++);
 i = p - environ;
 env_copy = (char **) g_malloc (sizeof (char *) * (i + 2));
 for (i = 0, p = environ; *p; p++) {
   if (strncmp (*p, "TERM=", 5) == 0) {
     env_copy [i++] = "TERM=xterm";
   } else if ((strncmp (*p, "COLUMNS=", 8) == 0) ||
	      (strncmp (*p, "LINES=", 6) == 0)) {
       continue;
   } else {
     env_copy [i++] = *p;
   }
 }
 
 env_copy [i++] = "COLORTERM=zterm";
 env_copy [i] = NULL;
 
 gtk_init(&argc, &args);
 
 win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 term = zvt_term_new ();
 gtk_container_add (GTK_CONTAINER(win), term);
 gtk_widget_show (term);
 gtk_widget_show (win);
 
 if (zvt_term_forkpty (ZVT_TERM (term), 0) == -1)
   {
     perror ("Error forking");
     exit (1);
   }
 
 if (execlp ("python", NULL, env_copy) == -1){
   perror ("Error calling execlp");
   exit(1);
 }
 
 gtk_main ();
 gtk_exit (0);
 return 0;
}
---------------------------------




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]