There is a program X written in rust, which is run by the root user via
sudo X run or
doas X run. It is located in
/usr/bin/ with the following permissions:
-rwxr-xr-x 1 root root 3714208 Oct 10 12:31 X
Okay, now we create a file /etc/dinit.d/X with the following contents:
type = process
command = /usr/bin/X run
logfile = /var/log/dinit/X.log
Startup:
~ ❯ doas dinitctl start X
Service 'X' started.
~ ❯ doas dinitctl status X
Service: X
State: STOPPED (terminated; unknown reason)
In
/var/log/dinit/X.log there is only this:
thread 'main' panicked at src/daemon.rs:450:67:
called `Result::unwrap()` on an `Err` value: Os { code: 25, kind: Uncategorized, message: "Inappropriate ioctl for device" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Where do I add this "RUST_BACKTRACE=1" and what do I do next?
Hi.
This program works outside of Dinit environment? (E.g. manual running from shell)
mobin2008, Hi! Yes, it is a simple utility that runs from the terminal using the commands above. It has this systemd service for starting (I have not tested it):
[Unit]
Description=Description program
[Service]
ExecStart=/usr/bin/X run
[Install]
WantedBy=multi-user.target
I would guess from the error message ("inappropriate ioctl for device") that it is expecting to be run with input/output connected to a terminal (tty). Does that seem like it would be the case?
I'd also guess from the source filename ("demon.rs") that it might be trying to background itself. This is not the ideal for how programs should behave under dinit (or any other modern service manager); you might want to check if there is a command line option to inhibit that.
(I know nothing about this "X" other than what I've been able to infer here and can't find a git repo or website for it, so I'm really mostly guessing).
The problem was in the source code.