Here you go. This code implements a simple command processor, one command of which starts up a gtk app. I tried it with an app of mine called "ngdcs" and it works. You might
want to read up on fork and exec ("man fork", "man execv") but this does work for me:
#include <stdio.h> #include <stdlib.h> int main() { int pid; char *argv[2]; char command[80]; printf("Enter command, either gtk or sayhello: "); while (fgets(command, sizeof(command), stdin) != NULL) { if (strcmp(command, "gtk\n") == 0) { pid = fork(); if (pid == 0) { argv[0] = "/usr/local/bin/ngdcs"; argv[1] = NULL; (void)execv(argv[0], argv); printf("execv failed!\n"); exit(1); } } else if (strcmp(command, "sayhello\n") == 0) printf("hello\n"); else printf("bad command\n"); printf("Enter command, either gtk or sayhello: "); } } From: Abhinav singh [abhinavksingh93 gmail com]
Sent: Thursday, June 05, 2014 8:52 AM To: Mazer, Alan S (389M) Cc: gtkmm-list gnome org Subject: Re: Running Gtk application in new terminal On Thu, Jun 5, 2014 at 8:57 PM, Alan Mazer
<alan s mazer jpl nasa gov> wrote:
Yes, this is running in a nix* environment. Can you please provide me link of tutorial related to fork/exec or some code structure which implement something similar to what you are saying.
Thanks,
Abhinav
|