在Android的strace的shell命令的问题 [英] strace shell command issue in Android

查看:252
本文介绍了在Android的strace的shell命令的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建一个监控应用程序,它在后台运行,并可以记录当前正在使用运行的应用程序执行的系统调用的的strace 的命令。

I'm building a monitor app, which runs in background and logs the system calls executed by currently running application using the strace command.

String cmd="strace -p "+processID+" -o /mnt/sdcard/traceFile_"+processID+".txt";
Runtime.getRuntime().exec(cmd);

下面的进程ID 的是目前正在运行的进程是从实现一些其他的方法,得到了PID。它记录的第一个应用程序,它监视正确地与所有执行系统调用信息的系统调用。但是,当一个新的应用程序被启动(第二个起),在进程ID 的正确更新,但该文件的 traceFile_processID 被写成一个空文件。 我无法弄清楚,为什么它的发生。是不是因为使用strace执行的第一个应用程序监控仍然存在?如果是的话我怎么能执行一个^ C终止该会话并启动一个新的作为亚行的shell命令提示符? PLZ帮我.....

Here processID is the PID of currently running process which is got from some other method implemented. It logs the system calls of the first app it monitors properly with all executed system call information. But when a new app is started(second one onwards), the processID is updated correctly, but the file traceFile_processID is written as an empty file. I'm not able to figure out why its happening. Is it because the strace execution of first app monitored still there?? If so how I can execute a ^C to terminate that session and start a new one as in adb shell command prompt?? Plz help me.....

推荐答案

如果你想^ C照你这么说,你真的要求的是如何提高所谓SIGINT给定的进程ID的信号。你可以做到这一点仅仅通过杀(进程ID,SIGINT); - 这相当于pressing按Ctrl-C键盘目标进程

If you want to "^C" as you say, what you're really asking for is how to raise the signal called SIGINT to the given processID. You can do that simply by kill(processID, SIGINT); - this is equivalent to pressing Ctrl-C on the keyboard for the target process.

这篇关于在Android的strace的shell命令的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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