A
andreas
Hello all,
I'm using an unstable debian distribution (Debian 2.6.18-3) and at some
day I found several artsd processes running in the process list. Normally
there should be only one sound server.
Now I started thinking about how to reduce the artsd process count using a
perl script and wrote something which works and can possibly be used to
remove any processes (cron etc.)
#!/usr/bin/perl -w
# file: killartsd.pl
# kill additional artsd processes - only one is required!
# (c)2006 Andreas Mueller andreas%at%poipoi.de
#####################################
# get artsd process ids from ps piped into a sed script
$plist=qx'ps h -C artsd | sed "s/\(\([ 0-9]*\|[0-9]*\).*\)/\2/g"';
# remove space+newline to form a list of pids
$plist =~ s/ \n/,/g;
# remove the ugly last comma in that list $plength=length($plist);
$plist=substr($plist,0,$plength-1) unless $plength < 1 ;
# convert result to an array because kill() wants an array, isn't it?
@parray=split(/,/,$plist);
# how many process ids are there?
$numproc=@parray;
# kill all unless there is only one or none
kill ('KILL',@parray) unless $numproc < 2 ;
My question is whether one knows a better way to do the whole thing
or parts of the script?
best regards
-andreas
I'm using an unstable debian distribution (Debian 2.6.18-3) and at some
day I found several artsd processes running in the process list. Normally
there should be only one sound server.
Now I started thinking about how to reduce the artsd process count using a
perl script and wrote something which works and can possibly be used to
remove any processes (cron etc.)
#!/usr/bin/perl -w
# file: killartsd.pl
# kill additional artsd processes - only one is required!
# (c)2006 Andreas Mueller andreas%at%poipoi.de
#####################################
# get artsd process ids from ps piped into a sed script
$plist=qx'ps h -C artsd | sed "s/\(\([ 0-9]*\|[0-9]*\).*\)/\2/g"';
# remove space+newline to form a list of pids
$plist =~ s/ \n/,/g;
# remove the ugly last comma in that list $plength=length($plist);
$plist=substr($plist,0,$plength-1) unless $plength < 1 ;
# convert result to an array because kill() wants an array, isn't it?
@parray=split(/,/,$plist);
# how many process ids are there?
$numproc=@parray;
# kill all unless there is only one or none
kill ('KILL',@parray) unless $numproc < 2 ;
My question is whether one knows a better way to do the whole thing
or parts of the script?
best regards
-andreas