界面关闭时未删除 socat 设备文件

socat device files not removed when interface is closed

我正在使用 socat 版本 1.7.3.2 从 VLAN 以太网设备创建字符设备进行通信。我使用以下命令创建设备:

socat INTERFACE:wwan0.vlan_dev1,type=2 PTY,mode=0777,rawer,link="/dev/ser_vlan0" &

它创建文件为:

/dev/ser_vlan0 -> /dev/pts/22

即使删除了 wwan0 设备,文件 /dev/ser_vlan0/dev/pts/22 仍然存在。

有没有办法在 wwan0 不再存在时自动删除这些文件?

来自 socatOPTIONS 文档:

-t <超时>:

When one channel has reached EOF, the write part of the other channel is shut down. Then, socat waits seconds before terminating. Default is 0.5 seconds. This timeout only applies to addresses where write and read part can be closed independently. When during the timeout interval the read part gives EOF, socat terminates without awaiting the timeout.

您需要将 timeout 设置为 0