我正在尝试将Android中的 getevent 命令重定向到设备上的文件。
I'm trying to redirect the getevent command in Android to a file on the device.
I尝试过的。 getevent> / path / to / file ,但这无效。当我 CTRL + C 时,文件为空。
I tried. getevent > /path/to/file, but that didn't work. When I CTRL+C'd, the file was empty.
经过进一步调查,我发现它可以正常工作如果我使用 getevent 的 -c 标志,它告诉该过程在收到一定数量的事件后终止。这使我相信该问题与我正在终止该过程有关。当我使用 tee 而不是> 时,我看到直到该过程才会在stdout中显示输出
After further investigation, I discovered that it works if I use getevent's -c flag, which tells the process to terminate after a certain number of events are received. This leads me to believe that the problem is related to the fact that I'm killing the process. When I use tee instead of a >, I can see that the output does not show in stdout until the process finishes gracefully.
当然,问题在于 getevent 永远不会终止,我不能使用 -c 标志,因为我事先不知道会收到多少个事件。
The problem of course is that getevent never terminates, and I can't use the -c flag because I won't know beforehand how many events are going to be received.
如何重定向 getevent 以这样一种方式保存到文件中,即使在进程被杀死时也在那里?
How can I redirect the getevent to a file in such a way that it is there even when the process is killed?
如果
编辑:我通过进一步调查发现,如果我确保至少已发送25个事件,它将写入文件。但是,如果我确定已发送30个事件,则仅将这25个事件写入文件。
I've discovered through further investigation, that if I ensure that at least 25 events have been sent, it writes to the file. But if I ensure 30 events have been sent, only those 25 events will be written to the file. This confirmed my suspicion, that it's a buffer issue.
推荐答案最后,我不得不编写一个调用logcat -c的脚本,这证实了我的怀疑。循环1个。
In the end, I had to write a script calling logcat -c 1 in a loop.
更多推荐
如何将android的getevent输出重定向到文件?
发布评论