systemd service causing bash to miss signals?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I apologize for the vague subject.

The background: I've inherited some legacy software to manage.

This is on SLES12 SP5, running:

	systemd-228-157.40.1.x86_64

One element is a systemd-managed service, written in Perl, that in
turn, is using bash to generate random numbers (don't ask me why
this tactic was adopted).

Here's an isolation of that logic:

  pheonix:~ # cat /root/random_str.pl
  #!/usr/bin/perl
  print "$0 start ".time."\n";
  my $randStr = `cat /dev/urandom|tr -dc "a-zA-Z0-9"|fold -w 64|head -1`;
  print "$0 end ".time."\n";

You can run this from the command-line, to see how quickly it
nominally operates.

What I can reproduce in my environment, very reliably, is that when
this is invoked as a service:

- the 'head' command exits very quickly (to be expected)
- the shell does not exit (maybe missed a SIGCHILD?)
- 'fold' chews a CPU core
- A kernel trace shows that 'fold' is spinning on SIGPIPEs, as it's
  STDOUT is no longer connected to another process.

My service unit:

  pheonix:~ # cat /etc/systemd/system/random_str.service
  [Unit]
  Description=gernate random number
  After=network.target local-fs.target
  
  [Service]
  Type=oneshot
  RemainAfterExit=yes
  ExecStart=/root/random_str.pl
  ExecStop=/usr/bin/true
  #TimeoutSec=infinity
  TimeoutSec=900
  
  [Install]
  WantedBy=multi-user.target

Easy to repro; this hangs forever, instead of exiting quickly.

  pheonix:~ # systemctl daemon-reload
  pheonix:~ # systemctl start random_str

Let me know if there are any other details of my environment that
would be helpful here.

-- 
Brian Reichert				<reichert@xxxxxxxxxxx>
BSD admin/developer at large	



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux