Pro*C and fork problem

From: Reynaldo Paulo <rpaulo_at_metz.une.edu.au>
Date: 24 Sep 93 06:30:00 GMT
Message-ID: <2054_at_grivel.une.edu.au>


Has anyone experienced this problem? I bumped into it when I included 'EXEC SQL' stuff in my C program that uses fork. The program is like this.

#include <stdio.h>

EXEC SQL BEGIN DECLARE SECTION;

   VARCHAR       uid[20];
   VARCHAR       pwd[20];

EXEC SQL END DECLARE SECTION; EXEC SQL INCLUDE sqlca;

main()
{

/* hardwiring my oracle username and password myname/mypass */  

   strcpy(uid.arr, "myname");
   uid.len = 6;
   strcpy(pwd.arr, "mypass");
   pwd.len = 6;

   printf("\nConnecting to Oracle server as %s\n", uid.arr);    EXEC SQL WHENEVER SQLERROR GOTO connect_error;    EXEC SQL CONNECT :uid IDENTIFIED BY :pwd;    printf("%cConnected.",7);

   switch (fork()) {

      case -1: printf("cann't fork\n");
               break;
      case  0: execlp("who","who",NULL);
               break;
      default: if (wait(NULL) == -1) 
                  perror("wait");
               break;

   }

   exit (0);

connect_error:

   EXEC SQL WHENEVER SQLERROR CONTINUE;
   printf("%s\n", sqlca.sqlerrm.sqlerrmc);    EXEC SQL ROLLBACK RELEASE;
   exit (-1);
}

Removing the embedded SQL stuff, the program works perfectly fine. It forks a child process and runs the who command. The parent waits and then terminates properly.

After I added the SQL stuff, the program still forks but when the parent executes the wait, it returns with -1 and the perror displays "wait: interrupted system call". Is the behaviour of wait affected/changed in some way by the inclusion of the SQL stuff? Quite strange.

I'm using Pro*C ver. 1.3.18.1.3.

Thanks in advance for some explanations.

+---------------------------------------------------------------------------+

|Rey V. Paulo | "I am not bound to please thee with my |
|University of New England | answer." |
|Internet: rpaulo_at_metz.une.edu.au | - Shylock in The Merchant of Venice |
+---------------------------------------------------------------------------+
Received on Fri Sep 24 1993 - 08:30:00 CEST

Original text of this message