0

是否可以在不修改代码的情况下在某些系统调用中同步两个 linux 进程?

一个真实世界的例子:v4l2-ctl是一种可用于设置网络摄像头某些控件的工具。运行它后设置一些控件,ffmpeg用于用相机捕捉电影。但是,仅设置自己的一些控件并重置其他一些控件,会ffmpeg破坏v4l2-ctl.

现在,无需修改和重建其中一个或两个工具即可解决此问题。ffmpeg如果可以启动,这将是可能的,但在打开和配置后会被挂起/dev/video0(很可能发生了一些ioctls事情),然后v4l2-ctl会被调用以应用设置。之后,ffmpeg将恢复并使用正确的设置开始捕获。

这是否可以跟踪一个进程的 io 操作并通过简单的方式将其挂起?

4

1 回答 1

1

If you're feeling adventurous and don't mind the performance hit of using a debug-compiled ffmpeg, you could conceivably start it under gdb and set a breakpoint after opening /dev/video0 (or anywhere else. You'll need the source either way.)

You could then run the binary until it hits the breakpoint, tweak v4l2-ctl and then tell ffmpeg to continue past the breakpoint.

于 2013-03-09T23:17:17.373 回答