fork
- From: Matt Eisemann <meisemann dsrnet com>
- To: "gtk-list gnome org" <gtk-list gnome org>
- Subject: fork
- Date: Thu, 19 Oct 2000 10:19:15 -0400
Currently I am creating an application which spawns other unix tasks using
execle and am not sure if this is a GTK+ limitation or not but the user
selects from a CLIST a row , which represents a task, to start. Below is
the start_task code, which works fine if the input parameters are right,
however if the parameters are not all right, then I get a unhealthy <async>
error followed by a Gdk-ERROR ** BadIDChoice (invalid resource ID chosen
for this connection).
Let me explain a little more carefully, there are Y number of parameters
that I want sent to UNIX and so I have chosen to use execle to execute
this. Previous to that I call the fork() function. Below is the code code
and some (i hope) extraneous stuff left out. The function below is a
callback after the user pushes a push button.
void start_tasks(GtkWidget *button, gpointer display_tasks)
{
char *env_init[]={"",NULL};
...
for(count = 0; count < num_tasks; count++)
{
/* string concatenate command together like 'ps -ef' */
if ((pid = fork()) < 0)
perror("fork error");
else if(pid == 0)
{
glfio_printf("pid : %d \n",(int)getpid());
command = execle(executable, arg1,arg2,arg3,(char *) 0, env_init);
if(command < 0)
{
perror("execle error");
printf("error starting task: %s
\n",tasks->task_list[row].executable);
}
}
if((pid !=0)&&(exe_status !=FALSE)
{
/* ------------------------------------------------
-- save the pid of new process
--------------------------------------------------- */
printf("new process id: %d \n",pid);
tasks->task_list[row].process_id = pid;
}
/* some other stuff */
} /* end for */
Do I need a waitpid when the execle command fails or is GTK+ not meant for
execle to fail. I certainly didn't expect my whole application to fail,
even if a task fails to start.
Thanks ahead of time for your help.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]