简体   繁体   English

调试从Linux中的另一个C ++应用程序启动的python脚本

[英]Debugging of python script launched from another C++ application in Linux

I have a C++ desktop application in linux and it executes a Python program. 我在linux中有一个C ++桌面应用程序,它执行一个Python程序。 I am using execl to run the python program as below: 我使用execl运行python程序如下:

 execl("python3", "Sample.py",NULL);

My query is with respect to debugging this python program. 我的查询是关于调试这个python程序。 I am adding the following line to enable debugging in the python program: 我添加以下行以在python程序中启用调试:

   import pdb; pdb.set_trace();

However, I want this python program to be launched in some console/terminal so that I can input the debugging parameters(like c,n etc). 但是,我想在一些控制台/终端中启动这个python程序,以便我可以输入调试参数(如c,n等)。

So how can I achieve this using execl function or is there any other method for this? 那么如何使用execl函数实现这一点,还是有其他方法呢? Please suggest. 请建议。

Thanks. 谢谢。

I used the following method to enable debugging of a python program from my application. 我使用以下方法从我的应用程序启用python程序的调试。

execl("/bin/sh","sh","-c","gnome-terminal -- python Sample.py",(char*)NULL); execl(“/ bin / sh”,“sh”,“ - c”,“gnome-terminal - python Sample.py”,(char *)NULL);

However, with the above approach I was not able to wait for the python process to exit/terminate as execl creates gnome-terminal process and that in-turn creates Python process. 但是,通过上述方法,我无法等待python进程退出/终止,因为execl创建了gnome-terminal进程,并且反过来创建了Python进程。 To overcome that I am looking for a python process like a pslookup after execl and waiting for it to complete. 为了克服这个问题,我在execl之后寻找像pslookup这样的python进程并等待它完成。

Please suggest if there are any better ways of doing it. 请建议是否有更好的方法。

Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM