我怎么printf()的调用后,execlp()的一个子进程? [英] How do I printf() after a call to execlp() in a child process?

查看:113
本文介绍了我怎么printf()的调用后,execlp()的一个子进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在试图调用execlp()子内后打印从一个子进程的消息。然而,没有在终端上显示的来电后execlp()。是什么原因导致我的printf()的调用不显示任何东西,这可怎么解决?

I am currently trying to print a message from a child process after calling execlp() within the child. However, nothing appears on the terminal after the call to execlp(). What causes my printf() calls to not display anything, and how can this be resolved?

推荐答案

一个成功的 execlp后() 电话,在你的previous程序中没有code都不会再次运行。该进程的内存空间将会覆盖新的进程。

After a successful execlp() call, no code in your previous program will ever run again. The process's memory space is overwritten with the new process.

如果您仍然需要做一些管理和孩子,那么你将要调用叉( )你叫 execlp()前。这会给你两个进程,然后你可以做两者之间的一些沟通。

If you still need to do some management with the child, then you will want to call fork() before you call execlp(). This will give you two processes, and you can then do some communication between the two.

这篇关于我怎么printf()的调用后,execlp()的一个子进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆