Discussion:
wxProcess::Exists() strange behaviour
Atti Szuts
2014-08-21 09:23:39 UTC
Permalink
I'd like to check running processes in my wxWidgets app. (they are started
from my app)

When I initialize process ID holder variables:

long authPID;

it loads 0 (zero) into authPID.

PID=0 always exists and running on Linux systems. (this is the Scheduler)
So checking zero PID returns true.

How can I avoid this in wxWidgets?
Always have to check if authPID is greater than zero, before calling
wxProcess::Exists(authPID)?


Thanks
A.
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Atti Szuts
2014-08-21 10:34:29 UTC
Permalink
How to reproduce?

This shows me 1 instead of 0:
wxMessageBox(wxString::Format(wxT("NULL process exists: %d"),
wxProcess::Exists(NULL)));



2014. augusztus 21., csÃŒtörtök 11:23:39 UTC+2 időpontban Atti Szuts a
Post by Atti Szuts
I'd like to check running processes in my wxWidgets app. (they are started
from my app)
long authPID;
it loads 0 (zero) into authPID.
PID=0 always exists and running on Linux systems. (this is the Scheduler)
So checking zero PID returns true.
How can I avoid this in wxWidgets?
Always have to check if authPID is greater than zero, before calling
wxProcess::Exists(authPID)?
Thanks
A.
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.

To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Vadim Zeitlin
2014-08-21 14:20:33 UTC
Permalink
On Thu, 21 Aug 2014 03:34:29 -0700 (PDT) Atti Szuts wrote:

AS> How to reproduce?
AS>
AS> This shows me 1 instead of 0:
AS> wxMessageBox(wxString::Format(wxT("NULL process exists: %d"),
AS> wxProcess::Exists(NULL)));

You're doing something that doesn't make any sense, namely passing NULL,
which is by convention used to represent pointers, to a function taking a
PID. I'm especially confused why do you still think it's the right thing to
do even after noticing yourself that PID 0 always exists.

If you want to check for the existence of the process, you must pass its
PID to Exists(). If your PID is 0, you have a bug somewhere else.

Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Loading...