登录到Oracle时system()返回-1,errno = 10 [英] system() returns -1, errno=10 when logged into Oracle
问题描述
在执行EXEC SQL CONNECT user/pass;
命令之后,system("")
返回errno = 10的-1.
After an EXEC SQL CONNECT user/pass;
command, system("")
returns a -1 with errno=10.
我们已将该程序从HP-UX上的Oracle 10g迁移到Red Hat Linux上的Oracle 11g.在HP-UX/Oracle 10g上没有发生这种情况.
We've migrated this program from Oracle 10g on HP-UX to Oracle 11g on Red Hat Linux. This was not happening on 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);
}
上面的代码返回以下内容:
The above code returns the following:
错误号的值:0
Value of errno: 0
状态:0
Oracle登录ID为user/pass
Oracle Login ID is user/pass
已连接到Oracle
Connected to Oracle
错误号的值:10
状态2:-1
发布了Oracle
错误号的值:10
状态3:-1
推荐答案
这是Oracle的糟糕之处.他们已经安装了SIGCHLD
处理程序,该处理程序可以获取退出的所有子进程,从而中断了应用程序中对子进程的任何使用.您可能可以通过在连接后调用signal(SIGCHLD,SIG_DFL)
来解决这些问题,以卸载它们的废话.
This is Oracle being awful. They've installed a SIGCHLD
handler that reaps any child process that exits, breaking any use of child processes in the application. You can probably fix it by calling signal(SIGCHLD,SIG_DFL)
after connecting to uninstall their nonsense.
这篇关于登录到Oracle时system()返回-1,errno = 10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!