c - system() keeps returning 127 -
i developing shared-library l used other system service s. in program need call small program p, uses oracle shared libraries.
the small program p packaged , installed correctly, , environment variables, such path,ld_library_path , oracle_home set correctly. can run p on command line without problem.
but when service s call library l runs small program p via system(), gives me return code 127. i've googled, people says it's command not found error, path issue, i've tried absolute path following
int status = system("/usr/bin/myprog --args"); if (status < 0) { ... } ret = wexitstatus(status);   ret still equals 127.
any idea please ? thank you.
update turns out service s launched via command daemon, in init.d script, have found following line:
daemon /usr/bin/myserv   if export explicitly environment variables (path, oracle_home , ld_library_path), works. don't know if daemon eliminates environment variables.
this excerpt man page system()
----------------------------------------------------------------- value returned -1 on  error  (e.g.,  fork(2)  failed),  ,     return  status  of command otherwise.   latter return status    in format specified in wait(2).   thus, exit code of command      wexitstatus(status).    in case /bin/sh not executed,    exit status of command exit(127)." -----------------------------------------------------------------   indicates 127 means /bin/sh not executed.
Comments
Post a Comment