LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-29-2015, 05:25 AM   #1
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
udev-initiated long-running processes under systemd without a service. Possible?


Before systemd, we had a long-established system for backing up to USB disks when they were plugged in. It did not hold up udev; the initial script started the long-running script in the background and itself terminated. Well sub-second.

When this system was installed on a systemd computer the backgrounded process tree silently disappeared. It was as if the tree had been sent SIGKILL. Nothing in the logs. Finally found https://forums.opensuse.org/showthre...ly-after-start and learned this is normal under systemd.

The systemd way is to use a systemd service to run the backup. Implemented that.

Decided I did not want the complexity (documentation, sample config files ...) of the backup system being different under systemd so I tried to find a common solution.

The first attempt was to daemonise the previously backgrounded process. Much to my surprise the tree headed by the daemon also silently disappeared.

The next attempt was to run the backup as an at job. Surely that must work. Nope.

From http://www.freedesktop.org/software/.../man/udev.html "Starting daemons or other long-running processes is not appropriate for udev; the forked processes, detached or not, will be unconditionally killed after the event handling has finished". Just because you are not paranoid does not mean they are not out to get you.

The backup runs perfectly when started at a command prompt and when run from cron. It runs with signals trapped and with stdout and stderr directed to log file so silently disappearing is unexpected.

Has anybody found a way to run udev-initiated long-running processes under systemd without a service?

(I have not yet tried emulating the at job method at a command prompt or of using a cron job instead of an at job)
 
Old 08-30-2015, 12:41 AM   #2
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,840

Rep: Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148
This udev approach using ENV{SYSTEMD_WANTS} might be helpful to you

http://blog.fraggod.net/2012/06/16/p...e-hotplug.html
 
2 members found this post helpful.
Old 08-31-2015, 04:15 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578

Original Poster
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Thanks ferrari, an interesting read.

I just re-tested the at job and this time it worked so, subject to further testing and coding error traps, that is the perfect solution because it is identical on all platforms.
 
Old 08-31-2015, 04:59 AM   #4
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,840

Rep: Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148Reputation: 1148
Quote:
I just re-tested the at job and this time it worked so, subject to further testing and coding error traps, that is the perfect solution because it is identical on all platforms.
Good to know. Thanks for the update.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
lfs 7.4 systemd udev-extras ibmercurial Linux From Scratch 1 12-13-2013 02:26 PM
[SOLVED] BLFS: Udev Extras (from systemd) error erkant Linux From Scratch 2 12-06-2012 12:47 PM
Boot Delay 30min: systemd-analyze blame systemd-tmpfiles-setup.service BGHolmes Fedora 0 07-27-2011 09:02 AM
how to monitor a running script initiated from remote computer babag Programming 3 04-07-2008 03:11 PM
How to automate detection & killing of long running ssh2 processes? yeo_harry Linux - Newbie 1 10-29-2007 03:28 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration