Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Determine if a process was spawed by screen

Reply
Thread Tools

Determine if a process was spawed by screen

 
 
Travis Spencer
Guest
Posts: n/a
 
      12-28-2003
Hello,

I am trying to figure out if a process was spawned by screen
(www.guckes.net/screen), in order to determine correctly if it is a runaway.

I have come up with a subroutine, but it is slow and doesn't perform
reliably. Can someone offer some suggestions that will speed it up and/or
increase its accuracy?

sub IsUsingScreen
{
my ($user, $pid) = @_;
my @process = `ps -p $pid -o user,pid,ppid,comm`;

# Calling `ps -p` returns two rows of output: a header row and the
# row of data. To get the parent process's user, pid, etc., the
# second row of output, $process[1], needs to be split on the
# whitespace delimiter after all leading whitespace has been
# trimmed off.
$process[1] =~ s/^\s+//m;
my ($p_user, $p_pid, $p_ppid, $p_comm) = split(/\s+/, $process[1]);

if ($p_user eq $user)
{
&IsUsingScreen($user, $p_ppid);
}
else
{
return $p_comm =~ /screen/;
}
}

Thanks.

--

Regards,

Travis Spencer
Portland, OR. USA


 
Reply With Quote
 
 
 
 
Travis Spencer
Guest
Posts: n/a
 
      12-28-2003
I guess I should have mentioned that my solution needs to run on Solaris 8+
and Redhat 9.

--

Regards,

Travis Spencer
Portland, OR. USA


 
Reply With Quote
 
 
 
 
Ben Morrow
Guest
Posts: n/a
 
      12-28-2003

"Travis Spencer" <(E-Mail Removed)> wrote:
> I guess I should have mentioned that my solution needs to
> run on Solaris 8+
> and Redhat 9.


Try using Proc:rocessTable form CPAN.

Ben

--
If you put all the prophets, | You'd have so much more reason
Mystics and saints | Than ever was born
In one room together, | Out of all of the conflicts of time.
http://www.velocityreviews.com/forums/(E-Mail Removed) |----------------+---------------| The Levellers, 'Believers'
 
Reply With Quote
 
Travis Spencer
Guest
Posts: n/a
 
      12-29-2003
Good suggestion, Ben. I have only installed a CPAN module once (in August).
I can't remember exactly how I did it though. I didn't have root privileges
then and I still don't If you have any suggestions that may jog my
memory, I would appreciate it.

--

Regards,

Travis Spencer
Portland, OR. USA

"Ben Morrow" <(E-Mail Removed)> wrote in message
news:bsnbid$i45$(E-Mail Removed)...
>
> "Travis Spencer" <(E-Mail Removed)> wrote:
> > I guess I should have mentioned that my solution needs to
> > run on Solaris 8+
> > and Redhat 9.

>
> Try using Proc:rocessTable form CPAN.
>
> Ben
>
> --
> If you put all the prophets, | You'd have so much more reason
> Mystics and saints | Than ever was born
> In one room together, | Out of all of the conflicts of time.
> (E-Mail Removed) |----------------+---------------| The Levellers,

'Believers'


 
Reply With Quote
 
Travis Spencer
Guest
Posts: n/a
 
      12-29-2003
Sorry, Ben, disregard that last post. I can be a real lazy sod sometimes.
I found the answers in the perlfaq and groups.google.

Have a nice day.

--

Regards,

Travis Spencer
Portland, OR. USA

"Ben Morrow" <(E-Mail Removed)> wrote in message
news:bsnbid$i45$(E-Mail Removed)...
>
> "Travis Spencer" <(E-Mail Removed)> wrote:
> > I guess I should have mentioned that my solution needs to
> > run on Solaris 8+
> > and Redhat 9.

>
> Try using Proc:rocessTable form CPAN.
>
> Ben
>
> --
> If you put all the prophets, | You'd have so much more reason
> Mystics and saints | Than ever was born
> In one room together, | Out of all of the conflicts of time.
> (E-Mail Removed) |----------------+---------------| The Levellers,

'Believers'


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
determine ASP.NET worker process user context programatically? =?Utf-8?B?RGFubnkgTWlsbGVy?= ASP .Net 3 10-03-2005 11:44 AM
How to determine DLLs loaded in 64bit process from a 32bit process? Pieter Windows 64bit 11 06-12-2005 04:34 PM
A process serving application pool 'DefaultAppPool' exceeded time limits during start up. The process id was '216'. jack ASP .Net 0 08-01-2004 09:49 PM
Determine when a process has ended? news.amnet.net.au Java 2 02-20-2004 03:37 PM
nuby: determine method passed and determine the receiver that received the method Peņa, Botp Ruby 1 01-24-2004 07:51 PM



Advertisments