1 Replies - 550 Views - Last Post: 26 March 2011 - 03:17 PM Rate Topic: -----

#1 unreal_origin  Icon User is offline

  • Wisdom Listens
  • member icon

Reputation: 4
  • View blog
  • Posts: 742
  • Joined: 21-April 05

Additional input to execvp after initial call

Posted 26 March 2011 - 02:48 PM

What I am trying to do is fork a process that runs gdb in the background on some program, I start gdb with the execvp call, here is what I have this far:

char *args[] = {"gdb","test/a.out",(char *) 0 };

if (execvp("gdb",args)==-1)
   {
      printf("execv failed\n");
      return -1;
   }
   //return 0; //this was added as a test
   //printf("TEST!!!!!!!!!!!!!!!!!!!!!\n\n\n\n\n\n\n\n\n\n"); /*When this line is uncommented I do not see this show up in the terminal*/
   fprintf(stdin,"%s","run");



There has to be some way that run additional commands to gdb. Any suggestions?

This post has been edited by unreal_origin: 26 March 2011 - 02:50 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Additional input to execvp after initial call

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6066
  • View blog
  • Posts: 23,526
  • Joined: 23-August 08

Re: Additional input to execvp after initial call

Posted 26 March 2011 - 03:17 PM

You need to use popen() to return a FILE * you can write to. However, it's a one-way pipe; you can't also read from it, so I'm not sure if that's going to suit your needs.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1