[comp.databases] ORACLE SHADOW PROCESS AND SIGNALS UNDER UNIX

jon@fdmetd.uucp (Jon Ivar Tr|stheim) (08/28/90)

I am running ORACLE 6.0.26.9.1 on an NCR TOWER 32/600 and have BIG
problem with system call and subroutine call in my Pro*C code.

In the Oracle Installation & User's Guide ORACLE says that under TOWER
UNIX, certian operating system call may interfere with the functioning
of the ORACLE precompilers ??????????

What does this mean !!!!

So far it seems to me that the ORACLE SHADOW PROCESS tries to interrupt
every sysetm call or subroutine i execute. 

In my test program below i receive signal 18 SIGCLD, and errno has been
set equal 4 EINTR (Interupted system call).

Why ?


What is the correct way to set up signal-handling in ORACLE 6.0.


Is this an BUGG ?, or what......


I would be very pleased if someone could tell me what is going one back
there (in the oracle shadow process), and why this shadow process tries
to send signal 15 SIGTERM, and also tries to interrupt system call when
in kernel mode.


-----------------------Test program starts here----------------------------




#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
#include <memory.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <uabincl/uab.h>
#include <uabincl/uabglobal.h>
#include <pwd.h>

EXEC SQL INCLUDE SQLCA.H;
EXEC SQL INCLUDE .. / .. / "uabincl" / UABSCHEMA.H;

#define	ERR -1

extern  int errno;
extern  char    *sys_errlist[];

EXEC SQL INCLUDE SQLCA.H;

EXEC SQL BEGIN DECLARE SECTION;
VARCHAR   H_bruker_id[11];
short int tull;
EXEC SQL END DECLARE SECTION;

extern  FILE    *Uab_log;
extern	int		Server_debug;

static	char *SCCS_filename = "uabf.c";
static 	char *target_filename = "dill";

/*-------------------------------------------------------------------*/
/* connect_to_oracle() - VOID                                        */
/*-------------------------------------------------------------------*/
int con_oracle(user)
char    *user;
{

    EXEC SQL BEGIN DECLARE SECTION;
        VARCHAR uid[10];
    EXEC SQL END DECLARE SECTION;

    /* strcpy(uid.arr, user); */
    strcpy(uid.arr,"/");
    uid.len = strlen(uid.arr);

    EXEC SQL WHENEVER SQLERROR CONTINUE;
    EXEC SQL CONNECT :uid;

    if (sqlca.sqlcode != 0) {
     	fprintf(stderr, "SQL-FEIL in connect - no %d\n", sqlca.sqlcode);
       	fprintf(stderr, "Error text: %s\n", sqlca.sqlerrm.sqlerrmc);
        EXEC SQL ROLLBACK WORK;
		return ERR;
    }

    return OK;
}


/*-------------------------------------------------------------------*/
/* disconnect_oracle() - disconnect from Oracle                      */
/*-------------------------------------------------------------------*/
disconnect_oracle()
{
    EXEC SQL BEGIN DECLARE SECTION;
        VARCHAR uid[10];
    EXEC SQL END DECLARE SECTION;


    EXEC SQL COMMIT WORK RELEASE;

    return OK;
}

/*----------------------------------------------------------*/
/* catch_signal() - chatch signals                          */
/* -------------------------------------------------------- */
void  catch_signal(signo)
int signo;
{
    extern  void    set_signal_catch();

    if (signo == SIGTERM || signo == SIGHUP || signo == SIGINT){
       	fprintf(stderr,"PROCESS (%d) Avbrutt med signal %d, errno=%d\n",
				getpid(), signo, errno);
        disconnect_oracle();
		exit(0);
    } else
       	fprintf(stderr, "PROCESS (%d) received signal %d\n", getpid(), signo);

    if (signo == SIGILL || signo == SIGBUS || signo == SIGSEGV ||
            signo == SIGSYS){
       	fprintf(stderr,"PROCESS (%d) Termination caused by signal %d\n",
				signo);
		disconnect_oracle();
		exit(0);
    }
    set_signal_catch();           /* Reset the signals     */
}


/* ------------------------------------------------------------ */
/* set_signal_catch() - Specify which signals are to be catched */
/* ------------------------------------------------------------ */
void set_signal_catch()
{

    signal(SIGINT, catch_signal);
    signal(SIGTERM, catch_signal);
    signal(SIGHUP, catch_signal);
    signal(SIGQUIT, catch_signal);
    signal(SIGILL, catch_signal);
    signal(SIGTRAP, catch_signal);
    signal(SIGIOT, catch_signal);
    signal(SIGEMT, catch_signal);
    signal(SIGFPE, catch_signal);
    signal(SIGBUS,  catch_signal);
    signal(SIGSEGV, catch_signal);
    signal(SIGSYS, catch_signal);
    signal(SIGALRM, catch_signal);
    signal(SIGPWR, catch_signal);
}

/*-------------------------------------------------------------------*/
/* catch_15() - special catch routine for signal SIGTERM (15)        */
/*-------------------------------------------------------------------*/
catch_15(signo)
int signo;
{
    signal(SIGTERM, catch_15);
  	fprintf(stderr, "catch_15():- Received signal %d\n", signo);
}



main(argc, argv)
int argc;
char    *argv[];
{
    UABF    tmp_uabf;
    char    buff[BUF_SZ], *getenv();
    void    catch_signal(), set_signal_catch();
    char    c;
    long    clock;
	struct	passwd	*passwd;
	char	cmd_string[256];
    int     (*sigcld)();

    extern  int optind;
    extern  char    *optarg;
	extern	struct	passwd	*getpwuid();


    /* Specify which signals are to be catched and action*/
    set_signal_catch();

    /* Connect to the oracle database       */
    if (con_oracle("ops$uab") != OK){
    	fprintf(stderr, "Connect faild:\n");
		exit(1);
    }
	else
		fprintf(stderr, "Connect til ORACLE OK\n");



	/* Do some test stuff, just to some thing */

    EXEC SQL DECLARE C1 CURSOR FOR
        SELECT bruker_id FROM bruker

    EXEC SQL OPEN C1;

    while(TRUE) {
        /* Get a user */
        EXEC SQL FETCH C1 INTO :H_bruker_id;

        if (sqlca.sqlcode != 0) {
			if (sqlca.sqlcode == 1403){
				fprintf(stderr,"Siste Row var %s\n", H_bruker_id.arr);
			}
			else {
				fprintf(stderr,"Error during fetch %d %s\n",
							sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
			}
            break;
		}
		fprintf(stderr,"Bruker --> %s\n",H_bruker_id.arr);
	}




    sigcld = signal(SIGCLD, catch_15);
    if (sigcld == SIG_IGN || sigcld == SIG_DFL)
        signal(SIGCLD, sigcld);




******************************************

My question is why do i get signal 15 SIGTERM back ??????????????????????????

	errno = 0;

	if (system("ls -l |more") != 0) {
		fprintf(stderr,"(1) errno = %d, %s\n", errno, sys_errlist[errno]);
	}


******************************************


    sprintf(cmd_string, "get -p s.%s >%s", SCCS_filename, 
										target_filename);

    /* This should be replaced with exec() for speed */
    signal(SIGTERM, catch_15);


    sigcld = signal(SIGCLD, catch_15);
    if (sigcld == SIG_IGN || sigcld == SIG_DFL)
        signal(SIGCLD, sigcld);

	errno = 0;

    if (system(cmd_string) != 0){
       signal(SIGTERM, catch_signal);
		fprintf(stderr,"(2) errno = %d, %s\n", errno, sys_errlist[errno]);
      	fprintf(stderr, "SCCS, Kommando %s feilet\n", cmd_string);
    }
    signal(SIGTERM, catch_signal);
    signal(SIGCLD, sigcld);

	if (disconnect_oracle() == OK)
		fprintf(stderr, "Disconnect fra ORACLE OK\n");
}










Output from program starts here:




Connect til ORACLE OK
                                                                                                                                                                                                                                      
total 587
-rw-rw-rw-   1 uab      metode       781 Aug 28 12:46 Makefile
-rw-rw-rw-   1 uab      metode      1631 Aug 28 10:57 Makefile.fr
-rw-r-----   1 uab      metode     11029 Aug 28 15:11 dill
-rwxr-x---   1 uab      metode    170485 Aug 28 15:10 ora-test
-rw-r-----   1 uab      metode     25648 Aug 28 15:09 ora-test.c
-rw-r-----   1 uab      metode     32753 Aug 28 15:09 ora-test.lis
-rw-r-----   1 uab      metode     34489 Aug 28 15:10 ora-test.o
-rw-r-----   1 uab      metode      6035 Aug 28 15:13 ora-test.pc
-rw-rw-rw-   1 uab      metode     11123 Aug 28 12:47 s.uabf.c
catch_15():- Received signal 18
(1) errno = 4, Interrupted system call
catch_15():- Received signal 18
1.1
468 lines
No id keywords (cm7)
Disconnect fra ORACLE OK


------------------------end output from test program---------------------------