Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
bgExec - need linux pid
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Peter Prockers  
View profile  
 More options Feb 7, 10:05 pm
Newsgroups: comp.lang.tcl
From: Peter Prockers <peter.prock...@googlemail.com>
Date: Tue, 7 Feb 2012 19:05:20 -0800 (PST)
Local: Tues, Feb 7 2012 10:05 pm
Subject: bgExec - need linux pid
At the moment I am using bgExec and I would use something similar if
needed. http://theory.asu.ru/public/download/sites/wiki.tcl.tk/12704

The process I run will run forever, unless killed. Even if the file
channel is closed, the process remains running.

To kill the process I would need to know pid, which I can see with ps
ux in linux console.

How can I get the linux pid (ps ux) after starting a process? I could
phrase "ps ux" before and after bgExec but I am looking for a more
elegant way. How to do it?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Gay  
View profile  
 More options Feb 7, 10:44 pm
Newsgroups: comp.lang.tcl
From: Ian Gay <g...@sfuu.ca>
Date: Tue, 07 Feb 2012 19:44:12 -0800
Local: Tues, Feb 7 2012 10:44 pm
Subject: Re: bgExec - need linux pid

Peter Prockers wrote:
> At the moment I am using bgExec and I would use something similar if
> needed. http://theory.asu.ru/public/download/sites/wiki.tcl.tk/12704

> The process I run will run forever, unless killed. Even if the file
> channel is closed, the process remains running.

> To kill the process I would need to know pid, which I can see with ps
> ux in linux console.

> How can I get the linux pid (ps ux) after starting a process? I could
> phrase "ps ux" before and after bgExec but I am looking for a more
> elegant way. How to do it?

--

If you know the process name you could use pgrep.
(And indeed, you could kill with pkill.)

*********** To reply by e-mail, make w single in address **************


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
M. Strobel  
View profile  
 More options Feb 8, 4:05 am
Newsgroups: comp.lang.tcl
From: "M. Strobel" <sorry_no_mail_h...@nowhere.dee>
Date: Wed, 08 Feb 2012 10:05:54 +0100
Local: Wed, Feb 8 2012 4:05 am
Subject: Re: bgExec - need linux pid
Am 08.02.2012 04:05, schrieb Peter Prockers:

> At the moment I am using bgExec and I would use something similar if
> needed. http://theory.asu.ru/public/download/sites/wiki.tcl.tk/12704

> The process I run will run forever, unless killed. Even if the file
> channel is closed, the process remains running.

> To kill the process I would need to know pid, which I can see with ps
> ux in linux console.

> How can I get the linux pid (ps ux) after starting a process? I could
> phrase "ps ux" before and after bgExec but I am looking for a more
> elegant way. How to do it?

Do it like this:

strobel@s114-intel:~> tclsh
% puts "my process id is: [pid]"
my process id is: 3741
%

/Str.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alexandre Ferrieux  
View profile  
 More options Feb 8, 5:30 am
Newsgroups: comp.lang.tcl
From: Alexandre Ferrieux <alexandre.ferri...@gmail.com>
Date: Wed, 8 Feb 2012 02:30:35 -0800 (PST)
Local: Wed, Feb 8 2012 5:30 am
Subject: Re: bgExec - need linux pid
On Feb 8, 4:05 am, Peter Prockers <peter.prock...@googlemail.com>
wrote:

> At the moment I am using bgExec and I would use something similar if
> needed.http://theory.asu.ru/public/download/sites/wiki.tcl.tk/12704

> The process I run will run forever, unless killed. Even if the file
> channel is closed, the process remains running.

> To kill the process I would need to know pid, which I can see with ps
> ux in linux console.

> How can I get the linux pid (ps ux) after starting a process? I could
> phrase "ps ux" before and after bgExec but I am looking for a more
> elegant way. How to do it?

 set ff [open "|some command w"]
 set p [pid $ff]
 close $ff

Note that if "some command" is a shell script, killing it will not
necessarily affect its children.
Two approaches to this problem:

 (1) arrange for 'some command' to remain the important process to
kill. Typically to do this in a shell script, you do all your
preparations in sh, then end with "exec foo bar baz ..." (this is sh's
exec, not Tcl's).

 (2) use 'setsid' to allocate a new process group, which will be -$p,
and kill the group:

 set ff [open "|setsid some command w"]
 set p [pid $ff]
 close $ff

 (later)

 kill -$p

-Alex


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
M. Strobel  
View profile  
 More options Feb 8, 5:58 am
Newsgroups: comp.lang.tcl
From: "M. Strobel" <sorry_no_mail_h...@nowhere.dee>
Date: Wed, 08 Feb 2012 11:58:56 +0100
Local: Wed, Feb 8 2012 5:58 am
Subject: Re: bgExec - need linux pid
Am 08.02.2012 04:05, schrieb Peter Prockers:

> At the moment I am using bgExec and I would use something similar if
> needed. http://theory.asu.ru/public/download/sites/wiki.tcl.tk/12704

> The process I run will run forever, unless killed. Even if the file
> channel is closed, the process remains running.

> To kill the process I would need to know pid, which I can see with ps
> ux in linux console.

> How can I get the linux pid (ps ux) after starting a process? I could
> phrase "ps ux" before and after bgExec but I am looking for a more
> elegant way. How to do it?

Alex Ferrieux just wrote it, but let me improve my first answer, I checked that myself:

The bgexec from http://wiki.tcl.tk/12704 does an open on a process pipeline, i.e.

open "| myprog"

The manual about open, command pipeline, says: The id of the spawned process is
accessible through the pid command, using the channel id returned by open as argument.

/Str.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Uwe Klein  
View profile  
 More options Feb 8, 11:42 am
Newsgroups: comp.lang.tcl
From: Uwe Klein <u...@klein-habertwedt.de>
Date: Wed, 08 Feb 2012 17:42:58 +0100
Local: Wed, Feb 8 2012 11:42 am
Subject: Re: bgExec - need linux pid

Peter Prockers wrote:
> At the moment I am using bgExec and I would use something similar if
> needed. http://theory.asu.ru/public/download/sites/wiki.tcl.tk/12704

> The process I run will run forever, unless killed. Even if the file
> channel is closed, the process remains running.

> To kill the process I would need to know pid, which I can see with ps
> ux in linux console.

> How can I get the linux pid (ps ux) after starting a process? I could
> phrase "ps ux" before and after bgExec but I am looking for a more
> elegant way. How to do it?

from the original blt man page on bgexec:
        You can also terminate the program by setting the variable
        myStatus.  If myStatus is set before du has completed, the
        process  is  killed. Under Unix, this is done sending by a
        configurable  signal  (by  default  it's  SIGKILL).  Under
        Win32,  this is done by calling TerminateProcess. It makes
        no difference what myStatus is set to.

there is refactored code from blt around that is accessed
via compilation by way of critcl.
        http://wiki.tcl.tk/13400

either use that or copy the SIGKILL functionality ( tclX comes to mind )

uwe


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »