Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Socat exclusive lock to PTY

Tags:

locking

socat

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

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

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

I am running on Ubuntu machine

like image 367
Raj Avatar asked Oct 04 '17 17:10

Raj


1 Answers

I understood now the TIOCEXCL flag in more detail. The application opening the PTY terminal should use this flag to obtain the exclusive lock. If we use it during PTY creation in socat command, it has no effect. But it does not give any error as well.

Thus the application should call the ioctl flag and it should be removed from here.

like image 156
Raj Avatar answered Oct 18 '22 02:10

Raj