I would like to create a systemd service unit file which has a Requires=
and After=
dependency on a psudeo terminal created by another service.
This site describes how to do this for a real device by adding TAG+=systemd
to a UDEV rule. So something like the following will generate a systemd device unit file which another service can depend on:
SUBSYSTEM=="tty", KERNEL=="ttyUSB0", PROGRAM="/etc/udev/usbtty.sh %k", SYMLINK+="ttyMyDev,OWNER="mydev", TAG+="systemd"
This will create a symlink at /dev/ttyMyDev
to a USB TTY device, as well as have systemd create a dev-ttyMyDev.device
unit.
However, for emulating virtual devices, we have a service which will create a pseudo terminal instead using the posix_openpt(3) I/F. I’d like this service to also be able to create a new UDEV rules file in /run/udev/rules.d
and to then have systemd be able to create a dev-ttyMyVirtualDev.device
unit file.
However, I can’t figure out how to get UDEV to recognize the device. For example, if I run the following socat
command it will create a /dev/pts/4
pseudo terminal:
$ sudo socat -d -d PTY,waitslave,echo=0,raw TCP-LISTEN:11313,reuseaddr,fork
2022/10/11 12:33:18 socat[24833] N PTY is /dev/pts/4
But I can’t query it with udevadm info
:
haz@haz-tower:/sys/devices/virtual/tty/ptmx$ udevadm info /dev/pts/4
Unknown device, --name=, --path=, or absolute path in /dev/ or /sys expected.
So I don’t know what to put in the KERNEL==
field of the UDEV rules file.
Does UDEV just not have the ability to trigger on the create of pseudo terminals?