3 Copyright (C) 2000 Kh. Naba Kumar Singh
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <sys/types.h>
25 #include <sys/unistd.h>
36 main (int argc
, char **argv
)
44 printf ("\nUsage:\n");
46 ("anjuta-launcher program_name [program_parameter ... ]\n\n");
50 if (strcmp (argv
[1], "--version") == 0)
52 printf ("anjuta-launcher version 0.1.2\n");
55 if (strcmp (argv
[1], "--__debug_terminal") == 0)
61 printf ("\nUsage:\n");
62 printf ("anjuta-launcher program_name [program_parameter ... ]\n\n");
65 fp
= fopen (argv
[2], "w");
68 g_warning ("Fatal Error: Cannot write to redirection file\n");
73 tty_name
= ttyname(0);
76 fprintf (fp
, "%s\n", tty_name
);
78 printf ("Debug Terminal for the process:\n");
79 printf ("-------------------------------\n");
85 fprintf (fp
, "__ERROR__\n");
87 g_warning ("Fatal Error: Unexpected error -- Unknowm tty\n");
94 arg_v
= g_malloc ((argc
) * sizeof (char *));
95 printf ("EXECUTING:\n");
96 for (i
= 1; i
< argc
; i
++)
98 printf ("%s ", argv
[i
]);
99 arg_v
[i
- 1] = g_strdup (argv
[i
]);
101 printf ("\n----------------------------------------------\n");
104 if ((pid
= fork ()) == 0)
106 execvp (argv
[1], arg_v
);
107 g_error ("Unable to execute the command (not found)\n");
111 printf ("\n----------------------------------------------\n");
112 printf ("There was an error in launching the program\n");
117 waitpid (pid
, &status
, 0);
118 printf ("\n----------------------------------------------\n");
120 waitpid (pid
, &status
, 0);
122 if (WIFSIGNALED (status
)) {
123 int signal
= WTERMSIG (status
);
125 printf ("Program has been terminated receiving signal %d (%s)\n", signal
, g_strsignal (signal
));
126 } else if (WIFEXITED (status
))
127 printf ("Program exited successfully with errcode (%d)\n", WEXITSTATUS (status
));
129 printf ("Press the Enter key to close this terminal ... \n");
131 return WEXITSTATUS (status
);