Advertisement
obernardovieira

Linux equivalent to Win32 ShellExecute

Sep 13th, 2013
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <sys/types.h>
  4.  
  5. int foo(char *adr[])
  6. {
  7.         pid_t pid;
  8.  
  9.         pid=fork();
  10.         if (pid==0)
  11.         {
  12.                 if (execv("/usr/bin/mozilla",adr)<0)
  13.                         return -1;
  14.                 else
  15.                         return 1;
  16.         }
  17.         else if(pid>0)
  18.                 return 2;
  19.         else
  20.                 return 0;
  21. }
  22.  
  23. int main(int argc,char *argv[])
  24. {
  25.         if (foo(argv)<=0)
  26.                 perror("foo");
  27.         return 0;
  28. }
  29. //by fnoyan
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement