c - 登录到Oracle时system()返回-1,errno = 10

标签 c oracle oracle-pro-c

EXEC SQL CONNECT user/pass;命令后,system("")返回errno = 10的-1。

我们已将该程序从HP-UX上的Oracle 10g迁移到Red Hat Linux上的Oracle 11g。在HP-UX / Oracle 10g上没有发生这种情况。

#include <errno.h>
#include <dirent.h>
#include <sys/types.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <sys/stat.h>

typedef char vc2[10];
typedef char vc4[20];

EXEC SQL INCLUDE sqlca;

char *oracleid = "user/pass";
char msg[400];
char env[20][200];
#define DEBUG 1
int  status = 1;


int main( argc, argv )
int argc;
char **argv;
{
    int        load_stat;

    EXEC SQL BEGIN DECLARE SECTION;

    EXEC SQL TYPE vc2 is STRING(11) REFERENCE;

    vc2        load_date;

    EXEC SQL END DECLARE SECTION;

        load_stat = system("");
sprintf(msg,"Value of errno: %d\n", errno);
fprintf(stderr,"%s\n",msg);
sprintf(msg, "status: %d\n ",load_stat);
fprintf(stderr,"%s\n",msg);

sprintf(msg, "ORACLE Logon ID is %s\n",oracleid);
fprintf(stderr,"%s\n",msg);

    EXEC SQL CONNECT :oracleid;

fprintf(stderr,"Connected to Oracle\n");
        load_stat = system("");
sprintf(msg,"Value of errno: %d\n", errno);
fprintf(stderr,"%s\n",msg);
sprintf(msg, "status 2: %d \n",load_stat);
fprintf(stderr,"%s\n",msg);

    EXEC SQL COMMIT RELEASE;

fprintf(stderr,"released Oracle\n");
        load_stat = system("");
sprintf(msg,"Value of errno: %d\n", errno);
fprintf(stderr,"%s\n",msg);
sprintf(msg, "status 3: %d \n",load_stat);
fprintf(stderr,"%s\n",msg);

exit(0);
}


上面的代码返回以下内容:


errno的值:0

状态:0

Oracle登录ID为用户/通过

连接到Oracle

值errno:10

状态2:-1

发布甲骨文

值errno:10

状态3:-1

最佳答案

这是甲骨文的可怕。他们已经安装了SIGCHLD处理程序,该处理程序可以获取退出的所有子进程,从而中断了应用程序中所有子进程的使用。您可以通过在连接后调用signal(SIGCHLD,SIG_DFL)来卸载它们的废话来修复它。

关于c - 登录到Oracle时system()返回-1,errno = 10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55307361/

相关文章:

SQL变量,怎么做?

c - 构建过程后如何在 cmake 中编译其他源文件

c - 程序在 VI 中导致段错误,但在 emacs 中工作正常

c - 检测 Linux 内核空间中的进程创建

sql - Oracle RAC 和序列

xml - 带有 Null 的 Oracle SELECT XMLELEMENT

c++ - 将 C++ 方法传递给 Pro*C 过程

c - 十进制到二进制转换器,控制台无响应

c - 如何从 C 函数返回二维数组?