Mailinglist Archive: yast-devel (101 mails)

< Previous Next >
[yast-devel] Sending signals to background process
  • From: "Kevin James" <kjames@xxxxxxxxxx>
  • Date: Tue, 22 Jan 2008 13:50:41 +0000
  • Message-id: <4795F4B10200005100026873@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Hi,

I've been working on a YaST module for a while now, and one of the
things I needed to do was monitor a dd process running in the
background, to provide a progress bar. Part of this involved sending
Signal 10 (SIGUSR1) to dd to get it to print out the current progress -
in doing this I added a function to ag_background called SigSubprocess,
which is effectively a copy of the KillSubprocess function but it takes
a parameter and sends that parameter as the signal to the background
process.

e.g. SCR::Execute(.background.sig, 10);

I've included the patch here - is it possible to get this into the main
source tree? I'm sure it would be useful in other circumstances...

Cheers,
KEv.


--
Kevin James
Applied Technology Senior Strategist
Novell Global Enablement
------------------------
Novell, Inc.
http://www.novell.com

--- ag_background 2007-11-14 20:43:49.000000000 +0000
+++ /usr/lib/YaST2/servers_non_y2/ag_background 2008-01-22 13:40:33.000000000
+0000
@@ -75,6 +75,23 @@
}
}

+# send specified SIG to running subprocess
+sub SigSubprocess($)
+{
+
+ my ($sig) = @_;
+
+ if ($child_running)
+ {
+ kill($sig, $child_pid); # send SIG
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
sub ErrorPath($)
{
my ($p) = @_;
@@ -202,6 +219,10 @@
{
ycp::Return(KillSubprocess() ? 'true' : 'false');
}
+ elsif ($path eq '.sig')
+ {
+ ycp::Return(SigSubprocess("$arg") ? 'true' : 'false');
+ }
else
{
ErrorPath($path);

< Previous Next >
Follow Ups