fork and async problem

Currently I am working on an application which uses CLIST type list and 
after the user selectes the t items they want from the list, they push a 
button called 'start tasks' which starts the processes they have chosen 
from the list.   Once they hit the start tasks button there is a callback 
to the following function (some hopefully extraneous code left out for 

The tasks that are strarted by the user are read in from a text file and 
displayed in the list.  Each task is stored in a record and there is an 
array of records called
'all_tasks' seen below.  The actual problem is that once the 'start tasks' 
button is pushed, I get an unexpected async reply.  I am not using exit() 
so this is not directly answered in the FAQ.

void start_tasks(GtkWidget *button, gpointer display_tasks)
  /* declare variables */
  char executable[100];
  char socket[7];
  pid_t pid;

  printf(" length of list: %d \n",length);

  /* loop through all in list  */
  for(count = 0; count < length; count++)
    exe_status = TRUE:
    /* get selected rows and use as an index in array of possible tasks to 
start */
    row = (int)g_list_nth_data(GTK_CLIST(display_tasks)->selection,count);
    printf("row: %d \n",row);
    printf("directory path: %s \n",all_tasks[row].dir_path);

    /* convert number parameters to character strings */

    if ((pid = fork()) < 0)
      perror("fork error");
    else if(pid == 0)
                    all_tasks[row].tcp_port,socket, (char *) 0, env_init) < 
        perror("execle error");
        printf("error starting task: %s \n",all_tasks[row].executable);
        exe_status = FALSE;
   /*  save the pid for the started process.  */
   if ((pid !=0)&&(exe_status !=FALSE)
     printf("new proces id: %d \n",pid);
     all_tasks[row].process_id = pid;
  }  /* end for */

The above routine is a callback from a start task button push after the 
user has selected some tasks from the list.  The problem is then when 
pushed I eventually get an unexpected async reply  - am I using fork wrong 
to initiate these processes?  Am I being clear that I want to start any 
number of executables read in from a text file or not?

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]