一个后EXEC SQL CONNECT user/pass;命令,system("")返回一个-1,并将errno = 10。
我们已将该程序从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 …Run Code Online (Sandbox Code Playgroud) 当我在RHEL 7.4中运行以下C代码时:
errno = 0;
status = system("ls >> /tmp/test.txt");
sprintf(msg, "Value of errno: %d\n", errno);
sprintf(msg, "Status: %d ", status);
os_log_msg(msg);
Run Code Online (Sandbox Code Playgroud)
我得到的返回代码为-1且errno = 10(无子进程)。/tmp/test.txt文件实际上是创建的,因此可以运行,但是程序看到非零的返回码并退出。
问题是该命令在HP-UX 11.11中返回了0,但是我们迁移到RHEL 7.4,现在得到-1。