PipableOSProcess#notifyError

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

PipableOSProcess#notifyError

Aidan Gauland-2
Hi,

Why does the following statement not appear to do anything?  (I
expected an error window to pop up.)

(PipeableOSProcess command: 'false') notifyError.

Stepping through this with the debugger, I found that the
ExternalUnixOSProcess's runState is #unknownRunState instead of
#complete, the value it must be in order for #notifyError to do
anything.

--Aidan


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: PipableOSProcess#notifyError

Sean P. DeNigris
Administrator
Aidan Gauland-2 wrote
Why does the following statement not appear to do anything?  (I
expected an error window to pop up.)

(PipeableOSProcess command: 'false') notifyError.
#command: may return before the process is complete, so you have a race condition with #notifyError.  Try:
p := PipeableOSProcess command: 'false'.
(Delay forMilliseconds: 1000) wait.
p notifyError.

Sean
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: PipableOSProcess#notifyError

David T. Lewis
In reply to this post by Aidan Gauland-2
On Sat, Jan 01, 2011 at 07:05:14AM +0000, Aidan Gauland wrote:

> Hi,
>
> Why does the following statement not appear to do anything?  (I
> expected an error window to pop up.)
>
> (PipeableOSProcess command: 'false') notifyError.
>
> Stepping through this with the debugger, I found that the
> ExternalUnixOSProcess's runState is #unknownRunState instead of
> #complete, the value it must be in order for #notifyError to do
> anything.
>
> --Aidan

Hi Aidan,

I should answer this question in several parts. First, why are you getting
an "unknown run state"? I'm not sure of this, but it sounds like something
is not working right in the OSProcess command cleanup. There is a background
process that watches the external OS processes and updates their run state.
Sometimes this process can be terminated, especially if you are debugging
things, but it will be restarted the next time you start your image. So
I'm hoping this part of the problem will just go away; if not please let
us know what operating system (Mac, Linux ?) you are using and I'll try
to give a better answer.

Second, why does #notifyError not seem to work? This is a timing issue.
If you look at the #notifyError method, you'll see that it only creates
a notifier if the external process is complete. However, when you evaluate
"(PipeableOSProcess command: 'false') notifyError" you will be sending
#notifyError right away, before the external process has had a chance
to run and before Squeak has been notified about the change in run state
(it will go from #running to #complete after the operation system notifies
Squeak that the external process has exited). You can confirm this by
evaluating the following, which should produce a notifier window:

  | p |
  p := PipeableOSProcess command: 'false'.
  (Delay forSeconds: 1) wait.
  p notifyError.

Finally, what's up that that #notifyError method in the first place?
It's in a method category called "private" which means that other classes
should not be using it (i.e. the method is intended for private use by
PipeableOSProcess itself). But if you check for senders of #notifyError,
you will see that there are none. This is an error on the part of the
author of the class (that's me). It means that this is a left over junk
method that I should have removed from CommandShell, but apparently I
forgot to do so.

HTH,
Dave

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: PipableOSProcess#notifyError

Aidan Gauland-2
David T. Lewis <lewis <at> mail.msen.com> writes:
> [snip]
>
>   | p |
>   p := PipeableOSProcess command: 'false'.
>   (Delay forSeconds: 1) wait.
>   p notifyError.
>
> [snip]

Thanks, Dave.  This clears up a *lot*.  And that code does raise a
dialog.  But, yes, I shouldn't be using private methods.  I didn't
notice what category #notifyError was in.

#succeeded tells me if the command returned non-zero, but how do I get
the actual return code?

Also, I see that CommandShell and OSProcess haven't been updated since
2008.  Would you consider doing a cleanup of these packages?
i.e. Removing obsolete methods such as #notifyError, and making all
tests green in the latest version of Squeak.
CommandShellTestCase┬╗testPipeline65 and
CommandShellTestCase┬╗testPipeline66 are red (errors).  But that's
still really good: 385 out of 387 passes.

IOHandle
<http://wiki.squeak.org/squeak/uploads/996/IOHandleV1-2-dtl.sar>,
however, fails to load into the Squeak image Squeak4.2-10779-alpha.
Could you please fix that, too, if you have the time?

Thanks,
Aidan


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: PipableOSProcess#notifyError

David T. Lewis
On Sat, Jan 01, 2011 at 09:39:24PM +0000, Aidan Gauland wrote:

> David T. Lewis <lewis <at> mail.msen.com> writes:
> > [snip]
> >
> >   | p |
> >   p := PipeableOSProcess command: 'false'.
> >   (Delay forSeconds: 1) wait.
> >   p notifyError.
> >
> > [snip]
>
> Thanks, Dave.  This clears up a *lot*.  And that code does raise a
> dialog.  But, yes, I shouldn't be using private methods.  I didn't
> notice what category #notifyError was in.
>
> #succeeded tells me if the command returned non-zero, but how do I get
> the actual return code?

The PipeableOSProcess is a wrapper around an ExternalUnixOSProcess,
where the ExternalUnixOSProcess represents the actual process (in
this case a Unix process running the program /bin/false). The
PipeableOSProcess adds the higher level features needed to connect
pipes to the Unix process and make it interact with Squeak. So if
you want the exit status of the /bin/false program, you can get at
it like this:

| p |
p := PipeableOSProcess command: 'false'.
[p isComplete] whileFalse: [(Delay forMilliseconds: 10) wait].
p processProxy exitStatus ==> 256


> Also, I see that CommandShell and OSProcess haven't been updated since
> 2008.  Would you consider doing a cleanup of these packages?

I think you have an out of date version of OSProcess and CommandShell.
I don't keep the web pages updated on the Swiki very often, but the
actual OSProcess and CommandShell package are on SqueakSource at
http://www.squeaksource.com/OSProcess and http://www.squeaksource.com/CommandShell.
There have been dozens of updates since 2008, so you can load the
latest versions with a Monticello browser. The two packages that
you would load are OSProcess-dtl.58 and CommandShell-dtl.50.

> i.e. Removing obsolete methods such as #notifyError, and making all
> tests green in the latest version of Squeak.
> CommandShellTestCase??testPipeline65 and
> CommandShellTestCase??testPipeline66 are red (errors).  But that's
> still really good: 385 out of 387 passes.

On Linux with the standard VM, you should get 100% green on all tests,
except possibly for occasional intermittent failures related to timing.
If you still get failures after updating from SqueakSource, please let
me know.

> IOHandle
> <http://wiki.squeak.org/squeak/uploads/996/IOHandleV1-2-dtl.sar>,
> however, fails to load into the Squeak image Squeak4.2-10779-alpha.
> Could you please fix that, too, if you have the time?

I have not been keeping the IOHandle package up to date in recent
years. This was basically a proof of concept for some ideas I had
about restructuring some of the socket and file code in Squeak. I'm
not planning on doing anything further with this in the near term.

> Thanks,
> Aidan

You're welcome. Thanks for experimenting with this and for raising
some good questions!

Dave

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners