Exclusive Socat Lock for PTY

I would like only one process to open a PTY device created by socat. I used the following to create my_ser device, but it can be read / written by several processes.

socat -t 0 INTERFACE:my_nw,type=2 PTY,mode=0777,rawer,link=/dev/my_ser

I tried using socat -t 0 INTERFACE:my_nw,type=2 PTY,mode=0777,rawer,link=/dev/my_ser,ioctl-void=0x540c use the exclusive PTY lock (TIOCEXCL), but it does not work. I see that IOCTL is executing, but with no effect.

I am running an Ubuntu machine

+5
source share
1 answer

Now I understand the TIOCEXCL flag in more detail. An application that opens a PTY terminal must use this flag to obtain an exclusive lock. If we use it during the creation of PTY in the socat command, this has no effect. But that makes no mistake.

Therefore, the application should call the ioctl flag, and it should be removed here.

+5
source

Source: https://habr.com/ru/post/1272345/


All Articles