gpt4 book ai didi

C - 外部 ELF 加载

转载 作者:行者123 更新时间:2023-11-30 14:40:22 24 4
gpt4 key购买 nike

我需要从我的程序中调用外部程序。

但是,我只想加载一次;也就是说,



int proc(void *path) {

void *p;

// ...

//ELF loader
p = load_magic(path);

do {

register int t = fork();

if (!t) {
// push arguments and jump to entrypoint
exec_magic(p, _ARGS_); // execlp(path, _ARGS_);

_exit(-0x1);
}

// stuff

} while(CONDITION);

// ...

}


这可能吗?

最佳答案

查看此页面:https://linux.die.net/man/3/execvp - 看起来 exec 系列函数可能是满足您需求的解决方案。

关于C - 外部 ELF 加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55573515/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com