>>>> "Jonathan" == Jonathan Harris
<jhar(a)tardis.ed.ac.uk> writes:
Jonathan> Adrian,
Jonathan> sorry I haven't commented earlier; I've been away from
Jonathan> email for the last few days.
> >>>>> "Craig" == Craig Lanning
<CraigL(a)DyCon.com> writes:
>
Craig> This doesn't work for me on Win98 (mingw32). It actually
Craig> makes things worse.
>
> Hello Craig, thanks for the feedback.
>
> I am working on an improved patch.
>
> The issue seems to be that the process may be gone before my patch
> even gets the process handle from the process ID.
Hello Jonathan, thanks for your comments!
Below I am referring to the patch in the parent of your mail message,
http://www.xemacs.org/list-archives/xemacs-nt/9910/msg00069.html.
Jonathan> You've solved this problem by opening a handle on the
Jonathan> process, which means that the process will stick around
Jonathan> until you close the handle. Your change to
I do close the process-handle now (although the original patch
didn't).
Jonathan> wait_for_termination() is ugly but I can't think of any
Jonathan> other way round the problem of dealing with
Jonathan> call_process_cleanup(). You should probably change
Jonathan> wait_for_termination() so that on win32 its argument is
Jonathan> "phandle" rather than "pid".
Yes, my patch does that. I had to experience that calling
OpenProcess() in wait_for_termination() is too late. The child may
have terminated by then. I call it right after child_setup() in
Fcall_process_internal().
Jonathan> How about using WaitForSingleObject(pid, 1/10s) instead
Jonathan> of GetExitCodeProcess() in your do...while loop in
Jonathan> wait_for_termination(). That might make XEmacs to use a
Jonathan> lot less CPU and let its child process exit more
Jonathan> quickly. You'll obviously still need to call
Jonathan> GetExitCodeProcess() once after the child has really
Jonathan> terminated.
I like this, I'll try to use WaitForSingleObject().
Jonathan> On Windows 95/98 process IDs are negative(!) which
Jonathan> screws up in a call to make_int() in
Jonathan> Fcall_process_internal() by blowing the 30(?) bit lisp
Jonathan> integer size. There's a nasty hack in create_child at
Jonathan> line 450 of ntproc.c to get round this by making the PID
Jonathan> positive. The problem that Craig was experiencing with
Jonathan> your original patch may have been due to the fact that
Jonathan> you weren't renegativising the PID in the call to
Jonathan> OpenProcess(). Your code still has this problem. You
Jonathan> either have to include ntheap.h and make the pid passed
Jonathan> to OpenProcess negative if (os_subtype==OS_WIN95), or
Jonathan> you have to come up with a better general solution to
Jonathan> the negative pid problem.
I'll try to fix this as well.
Thanks for your help!
Adrian
Jonathan> Jonathan.
Jonathan> --
Jonathan> Jonathan Harris | jhar(a)tardis.ed.ac.uk
Jonathan> London, England | Jonathan.Harris(a)symbian.com