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
Testing for a process
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
  13 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
 
James Moe  
View profile  
 More options Sep 16 2012, 12:01 am
Newsgroups: comp.os.os2.programmer.misc
From: James Moe <jimoeDES...@sohnen-moe.com>
Date: Sat, 15 Sep 2012 21:01:01 -0700
Local: Sun, Sep 16 2012 12:01 am
Subject: Testing for a process
Hello,
  How do I test, from a program, if some other process is running given
its process ID (PID)?
  The external process is started with DosStartSession() and returns the
process ID since SSF_RELATED_CHILD is indicated. Unfortunately,
DosWaitChild() always returns ERROR_WAIT_NO_CHILDREN regardless of the
existence of the external process. I can see no obvious (to me) kernel
function that gives information about other processes.

--
James Moe
jmm-list at sohnen-moe dot com


 
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.
Steven Levine  
View profile  
 More options Sep 16 2012, 3:51 am
Newsgroups: comp.os.os2.programmer.misc
From: "Steven Levine" <stev...@nomail.earthlink.net>
Date: Sun, 16 Sep 2012 02:51:35 -0500
Local: Sun, Sep 16 2012 3:51 am
Subject: Re: Testing for a process
On Sun, 16 Sep 2012 04:01:01 UTC, James Moe

<jimoeDES...@sohnen-moe.com> wrote:

Hi James,

>   How do I test, from a program, if some other process is running given
> its process ID (PID)?

It depends on how you started the program.

>   The external process is started with DosStartSession() and returns the
> process ID since SSF_RELATED_CHILD is indicated. Unfortunately,
> DosWaitChild() always returns ERROR_WAIT_NO_CHILDREN regardless of the
> existence of the external process.

TTBOMK, you are mis-using DosWaitChild.  Note that the remarks say
that DosWaitChild is used to detect completion of programs started by
DosExecPgm.

To monitor session completion, use a termination queue.  You can also
use DosQuerySysState, but this is a bit of a hack.

Steven

--
---------------------------------------------------------------------
Steven Levine <stev...@earthlink.bogus.net>
eCS/Warp/DIY etc. www.scoug.com www.ecomstation.com
---------------------------------------------------------------------


 
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.
Dave Saville  
View profile  
 More options Sep 16 2012, 6:37 am
Newsgroups: comp.os.os2.programmer.misc
From: "Dave Saville" <d...@invalid.invalid>
Date: Sun, 16 Sep 2012 10:37:10 +0000 (UTC)
Local: Sun, Sep 16 2012 6:37 am
Subject: Re: Testing for a process
On Sun, 16 Sep 2012 04:01:01 UTC, James Moe

<jimoeDES...@sohnen-moe.com> wrote:
> Hello,
>   How do I test, from a program, if some other process is running given
> its process ID (PID)?
>   The external process is started with DosStartSession() and returns the
> process ID since SSF_RELATED_CHILD is indicated. Unfortunately,
> DosWaitChild() always returns ERROR_WAIT_NO_CHILDREN regardless of the
> existence of the external process. I can see no obvious (to me) kernel
> function that gives information about other processes.

BIt of a hack but you could do a popen() of PSTAT and parse the
output.

--
Regards
Dave Saville


 
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.
James Moe  
View profile  
 More options Sep 16 2012, 6:42 pm
Newsgroups: comp.os.os2.programmer.misc
From: James Moe <jimoeDES...@sohnen-moe.com>
Date: Sun, 16 Sep 2012 15:42:32 -0700
Local: Sun, Sep 16 2012 6:42 pm
Subject: Re: Testing for a process
On 09/16/2012 12:51 AM, Steven Levine wrote:

>>   The external process is started with DosStartSession() and returns the
>> process ID since SSF_RELATED_CHILD is indicated. Unfortunately,
>> DosWaitChild() always returns ERROR_WAIT_NO_CHILDREN regardless of the
>> existence of the external process.

> TTBOMK, you are mis-using DosWaitChild.  Note that the remarks say
> that DosWaitChild is used to detect completion of programs started by
> DosExecPgm.

  Oops. Missed that part.

> To monitor session completion, use a termination queue.  You can also
> use DosQuerySysState, but this is a bit of a hack.

Global.Hq is the handle for a termination queue.

REQUESTDATA request = {0};
PVOID pdata;
ULONG datalen,
      queue_posn;
BYTE priority;
APIRET rc;

queue_posn = 0;     // Start at beginning of queue; receives position.
priority   = 0;     // Minimal priority
if (NULLHANDLE != Global.Hq)
    rc = DosPeekQueue(Global.Hq, &request, &datalen, &pdata,
                &queue_posn, DCWW_NOWAIT, &priority, NULLHANDLE);

The return code, rc, is always ERROR_INVALID_PARAMETER (87). But I do
not see which parameter is invalid.

--
James Moe
jmm-list at sohnen-moe dot com


 
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.
Paul Ratcliffe  
View profile  
 More options Sep 16 2012, 8:15 pm
Newsgroups: comp.os.os2.programmer.misc
From: Paul Ratcliffe <ab...@orac12.clara34.co56.uk78>
Date: Mon, 17 Sep 2012 00:15:36 GMT
Local: Sun, Sep 16 2012 8:15 pm
Subject: Re: Testing for a process
On Sun, 16 Sep 2012 10:37:10 +0000 (UTC), Dave Saville

<d...@invalid.invalid> wrote:
>>   How do I test, from a program, if some other process is running given
>> its process ID (PID)?

> BIt of a hack but you could do a popen() of PSTAT and parse the
> output.

Oh for God's sake, NOOOOOOOOOO.

 
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.
Alex Taylor  
View profile  
 More options Sep 16 2012, 10:20 pm
Newsgroups: comp.os.os2.programmer.misc
From: "Alex Taylor" <mail...@reply.to.address>
Date: 16 Sep 2012 21:20:01 -0500
Local: Sun, Sep 16 2012 10:20 pm
Subject: Re: Testing for a process

On Sun, 16 Sep 2012 10:37:10 UTC, "Dave Saville" <d...@invalid.invalid> wrote:
> >   How do I test, from a program, if some other process is running given
> > its process ID (PID)?
> >   The external process is started with DosStartSession() and returns the
> > process ID since SSF_RELATED_CHILD is indicated. Unfortunately,
> > DosWaitChild() always returns ERROR_WAIT_NO_CHILDREN regardless of the
> > existence of the external process. I can see no obvious (to me) kernel
> > function that gives information about other processes.

> BIt of a hack but you could do a popen() of PSTAT and parse the
> output.

More than a bit... if that's the approach you want to take, it'd be far
more efficient to get a process list directly using DosQuerySysState().

--
Alex Taylor
Fukushima, Japan
http://www.altsan.org

Please take off hat when replying.


 
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.
Paul Ratcliffe  
View profile  
 More options Sep 17 2012, 12:20 pm
Newsgroups: comp.os.os2.programmer.misc
From: Paul Ratcliffe <ab...@orac12.clara34.co56.uk78>
Date: Mon, 17 Sep 2012 16:20:32 GMT
Local: Mon, Sep 17 2012 12:20 pm
Subject: Re: Testing for a process
On Sun, 16 Sep 2012 15:42:32 -0700, James Moe <jimoeDES...@sohnen-moe.com>
wrote:

You have to supply a semaphore handle with DCWW_NOWAIT according to CPREF.
Read the Remarks page for DosPeekQueue.

 
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.
James Moe  
View profile  
 More options Sep 18 2012, 1:43 am
Newsgroups: comp.os.os2.programmer.misc
From: James Moe <jimoeDES...@sohnen-moe.com>
Date: Mon, 17 Sep 2012 22:43:27 -0700
Local: Tues, Sep 18 2012 1:43 am
Subject: Re: Testing for a process
On 09/17/2012 09:20 AM, Paul Ratcliffe wrote:

>> The return code, rc, is always ERROR_INVALID_PARAMETER (87). But I do
>> not see which parameter is invalid.

> You have to supply a semaphore handle with DCWW_NOWAIT according to CPREF.
> Read the Remarks page for DosPeekQueue.

  Thank you.
  I did read the Remarks for DosPeekQueue(). The part about nowait and a
semaphore made it seem that the semaphore was optional.
  I modified the code to use DCWW_WAIT instead, without a semaphore. The
function never returned even after the external process ended. The
process did end badly; I ended it by sending an interrupt via a process
killer.
  Would a process ending that way fail to place anything in the
termination queue? I rather had the impression that the OS handled that
part of it, not the ending process.

--
James Moe
jmm-list at sohnen-moe dot com


 
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.
Steven Levine  
View profile  
 More options Sep 18 2012, 3:20 am
Newsgroups: comp.os.os2.programmer.misc
From: "Steven Levine" <stev...@nomail.earthlink.net>
Date: Tue, 18 Sep 2012 02:20:00 -0500
Subject: Re: Testing for a process
On Mon, 17 Sep 2012 16:20:32 UTC, Paul Ratcliffe

<ab...@orac12.clara34.co56.uk78> wrote:

Hi,

> > if (NULLHANDLE != Global.Hq)
> >     rc = DosPeekQueue(Global.Hq, &request, &datalen, &pdata,
> >               &queue_posn, DCWW_NOWAIT, &priority, NULLHANDLE);

> > The return code, rc, is always ERROR_INVALID_PARAMETER (87). But I do
> > not see which parameter is invalid.

> You have to supply a semaphore handle with DCWW_NOWAIT according to CPREF.
> Read the Remarks page for DosPeekQueue.

This is true.  See

  http://svn.netlabs.org/repos/fm2/trunk/dll/systemf.c

or

  http://svn.netlabs.org/fm2/browser/trunk/dll/systemf.c

for an implementation.  It's probably a bit more complicated than
James needs because it handles a large number of application types.

Steven

--
---------------------------------------------------------------------
Steven Levine <stev...@earthlink.bogus.net>
eCS/Warp/DIY etc. www.scoug.com www.ecomstation.com
---------------------------------------------------------------------


 
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.
Rich Walsh  
View profile  
 More options Sep 18 2012, 2:31 pm
Newsgroups: comp.os.os2.programmer.misc
From: "Rich Walsh" <spamyours...@127.0.0.1>
Date: 18 Sep 2012 18:31:27 GMT
Local: Tues, Sep 18 2012 2:31 pm
Subject: Re: Testing for a process

On Sun, 16 Sep 2012 04:01:01 UTC, James Moe wrote:
>   How do I test, from a program, if some other process is running given
> its process ID (PID)?
>   The external process is started with DosStartSession() and returns the
> process ID since SSF_RELATED_CHILD is indicated. Unfortunately,
> DosWaitChild() always returns ERROR_WAIT_NO_CHILDREN regardless of the
> existence of the external process. I can see no obvious (to me) kernel
> function that gives information about other processes.

As always, no one has asked the fundamental question:  "why are you using
DosStartSession() in the first place"?  It may be the correct solution for
the issue at hand - or its use could be totally boneheaded.  I don't see
how helping someone do the wrong thing is genuinely helpful.

So... what app is calling DosStartSession()? (PMMail, I'd guess.)
What program is it starting?  Are you positive that it needs a new session?
Does your app (or some functionality therein) have to block until this
mystery process terminates?  Etc, etc.

Also, have you considered using WinStartApp()?

--
== == almost usable email address:  Rich AT E-vertise DOT Com == ==


 
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.
James Moe  
View profile  
 More options Sep 18 2012, 2:31 pm
Newsgroups: comp.os.os2.programmer.misc
From: James Moe <jimoeDES...@sohnen-moe.com>
Date: Tue, 18 Sep 2012 11:31:26 -0700
Local: Tues, Sep 18 2012 2:31 pm
Subject: Re: Testing for a process
On 09/17/2012 10:43 PM, James Moe wrote:
>   I did read the Remarks for DosPeekQueue(). The part about nowait and a
> semaphore made it seem that the semaphore was optional.

  I was incorrect. The Remarks clearly state that a semaphore is required.

--
James Moe
jmm-list at sohnen-moe dot com


 
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.
James Moe  
View profile  
 More options Sep 19 2012, 1:28 pm
Newsgroups: comp.os.os2.programmer.misc
From: James Moe <jimoeDES...@sohnen-moe.com>
Date: Wed, 19 Sep 2012 10:28:53 -0700
Local: Wed, Sep 19 2012 1:28 pm
Subject: Re: Testing for a process
On 09/18/2012 11:31 AM, Rich Walsh wrote:

> So... what app is calling DosStartSession()? (PMMail, I'd guess.)
> What program is it starting?  Are you positive that it needs a new session?
> Does your app (or some functionality therein) have to block until this
> mystery process terminates?  Etc, etc.

  Yes, PMMail.
  It is starting stunnel, a security proxy. Stunnel provides encrypted
data transfer for PMMail.
  It originally used DosExecPgm() to start stunnel. DosStartSession()
can start a program without inheriting the current environment and file
handles. It was more of a debugging effort to eliminate a possibility
than any actual advantage of DosStartSession(). I then wanted to know if
the program was actually running, or be notified when it quit. Hence the
posting.

  (The problem I am having is with files being closed but randomly
unavailable, sometimes for many seconds. For instance, a file is
created, written, closed, all with standard C functions. That file may
then be copied to another file, or renamed. In either case, sometimes
the copy/rename returns error 13, Permission Denied.
  The last time I had a similar problem was when an external program was
started that inherited file handles, and closed those inherited handles
when it quit. The parent process was not pleased.)

> Also, have you considered using WinStartApp()?

  No, I had not.

--
James Moe
jmm-list at sohnen-moe dot com


 
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.
Paul Ratcliffe  
View profile  
 More options Sep 19 2012, 2:11 pm
Newsgroups: comp.os.os2.programmer.misc
From: Paul Ratcliffe <ab...@orac12.clara34.co56.uk78>
Date: Wed, 19 Sep 2012 18:11:33 GMT
Local: Wed, Sep 19 2012 2:11 pm
Subject: Re: Testing for a process
On Wed, 19 Sep 2012 10:28:53 -0700, James Moe <jimoeDES...@sohnen-moe.com>
wrote:

>   The last time I had a similar problem was when an external program was
> started that inherited file handles, and closed those inherited handles
> when it quit. The parent process was not pleased.)

All programs close all file handles when they exit. The child closing
its handles has no effect on those of the parent.
Your analysis is flawed somewhere.

 
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 »