Redian新闻
>
How to call a executable file on Unix?
avatar
How to call a executable file on Unix?# Unix - 噫吁兮,危乎高哉
a*e
1
I am writing a C++ program on Unix system. I want to call an executable file
in my
program.
It seems that the function system() is designed for calling system command.
Both _spawnl and _exeul only work on NT or Windows.
Which function should I use? Is there such a function in ANSI? If not, how to
solve this problem?
avatar
x*g
2
man exec

【在 a*****e 的大作中提到】
: I am writing a C++ program on Unix system. I want to call an executable file
: in my
: program.
: It seems that the function system() is designed for calling system command.
: Both _spawnl and _exeul only work on NT or Windows.
: Which function should I use? Is there such a function in ANSI? If not, how to
: solve this problem?

avatar
a*e
3
Thanks. I will try.

file
command.
to

【在 x******g 的大作中提到】
: man exec
avatar
c*r
4
"exec" won't be a "call" to a program, because it won't
return to the original process.
You need to do a fork() then exec() and wait -- basically, what system()
does (system() calls vfork() to be efficient)
Check system() again, it should work. You might forget to give
it the full path of the callee program.

【在 a*****e 的大作中提到】
: Thanks. I will try.
:
: file
: command.
: to

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。