c++启动新进程并终止现有进程

发布于 2024-11-14 06:55:49 字数 97 浏览 9 评论 0原文

我希望能够让更新程序应用程序启动应用程序的新版本,然后自行终止。

当我尝试通过“系统”调用新应用程序的“通常”方式时,更新程序永远不会退出。

想法?

I want to be able to have an updater application launch the new version of the application, then terminate itself.

When I try the 'usual' of calling the new application via 'system', the updater never exits.

Thoughts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

鹿童谣 2024-11-21 06:55:49

查看 Windows 上的 CreateProcess 或 < Unix 上的 href="http://linux.about.com/od/commands/l/blcmdln_exec.htm" rel="nofollow">exec 。使用宏创建操作系统特定代码的包装器。

Look into CreateProcess on Windows or exec on Unix. Use macros to create a wrapper over the OS specific code.

榆西 2024-11-21 06:55:49

exec 函数系列用新进程替换当前进程。如果 fork 后没有从子进程调用,这应该用新程序替换您的程序。

系统调用 fork,然后在子进程中执行 shell 并等待其返回,这就是您的更新程序不退出的原因。

请参阅 man 3 exec 和 man 3 system。

exec family of functions replaces current process with a new one. If not called from child after fork, this should replace your program with new one.

system calls fork and then executes shell in a child and waits for its return, that's why your updater does not exit.

See man 3 exec and man 3 system.

傲世九天 2024-11-21 06:55:49

您将需要类似于 Windows 上的 CreateProcess 的东西来创建和运行单独的进程。 system 调用将等待您输入的任何命令完成,然后返回。

You will need something along the lines of CreateProcess on Windows that creates and runs a separate process. The system call will wait for whatever command you entered to finish and then return.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文