Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: [SOLVED] Creating a runit service for iptsd on a Surface device (Read 1222 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[SOLVED] Creating a runit service for iptsd on a Surface device

I was able to install Artix on my Microsoft Surface Go tablet.  I followed the Arch install instructions here:

https://github.com/linux-surface/linux-surface/wiki/Installation-and-Setup#Arch

Everything translates directly to Artix except this last step of course:

Code: [Select]
systemctl enable iptsd

This service is needed for the touchscreen to work.  It can be started manually with the command "iptsd".  I created my own runit service for it.  The file "run" was stored in /etc/runit/sv/iptsd/ and contains:

Code: [Select]
#!/bin/sh
exec iptsd -n 2>&1

I just used the existing run file for cronie as a template.  My question is, what does the "-n 2>&1" part mean? The iptsd service now works as expected, I just want to understand what the script is doing.

By the way, anyone else reading this and wishing to do the same thing on a Surface device, don't forget to make the script executable and enable the service:

Code: [Select]
chmod a+x /etc/runit/sv/iptsd/run
ln -s /etc/runit/sv/iptsd /run/runit/service

Re: Creating a runit service for iptsd on a Surface device

Reply #1
The 2>&1 part means, ultimately, send error messages to the same place as the normal program output. If you were to make a /etc/runit/sv/iptsd/log, it would be able to save iptsd's error messages to the disk.

I could go on about the concepts of file descriptors, stdin, stdout and stderr, but I'm keeping this explanation simplified. If you want to read further, these are the keywords.

-n, from what I gathered from the documentation, is meaningless for iptsd, but for cronie, it makes it not detach from its parent program, which is necessary for runit to be able to monitor it. It's called "keeping in the foreground".

No -n is present on systemd, and it's a type simple (i.e. doesn't detach) service, therefore you could simplify the run script to

Code: [Select]
#!/bin/sh
exec iptsd 2>&1

The opposite is programs that detach from their parent program after initialization (what systemd calls Type=forking). Cronie does this by default (when no -n is given).

Runit doesn't like that and thinks the program died, and tries to spawn it again and again, which hammers the system. So for runit to work, all services must be "foreground"/not detach.

Hope this makes sense.


 

Re: Creating a runit service for iptsd on a Surface device

Reply #3
Thank you for the extra information and pointers to where to learn more.