Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Re: [cdt-core-dev] Problem cancelling a launch


I fixed the spawner problem (Bug Report #71601- Cannot kill child process launched via spawner) and tested it on W2K. Unfortunately I don't have machines with XP+cygwin & NT + cygwin. It would be nice if somebody volonteers to try updated version. I attached binary files and recommended testing method to the bug report in Bugzilla.


Thanks,

Alex Chapiro.



James Langley wrote:

Alex,

Not a critical issue.  We've already shipped once with this problem.  I
was just mopping up outstanding issues and spent some time looking into
this one.  It's certainly something that we'd like to get fixed, but
it's not seriously urgent.  I'd be happy to try out any revised versions
of the spawner code for you as and when you get round to making changes.

James

-----Original Message-----
From: Alex Chapiro [mailto:achapiro@xxxxxxx]
Sent: 23 July 2004 20:10
To: James Langley
Subject: Re: [cdt-core-dev] Problem cancelling a launch

Yes, all the processes are started via starter.exe. This is connected
with the fact that GenerateConsoleCtrlEvent sends CTRL-C not only to
child processes, but for main process as well. In starter we replace
default processing of CTRL-C avoiding its termination in case when
CTRL-C means something else (like in gdb case).

Is this problem absolutly critical for you, or you can wait at least
until next Tuesday (the week after next even better)?

James Langley wrote:

Alex,

Under what circumstances is starter.exe called?  Is it used to launch
all processes?  From casually browsing the code, it looks as though
the
starter includes code to pass CTRL-C on to console processes.  Is
there
any way for me to use this to launch my cygwin shell?  Perhaps the
function GenerateConsoleCtrlEvent is useful?  It's always possible
that
gdb's interrupt handling is done differently on Windows than the
cygwin
shell's and that might account for the difference in behaviour.

The test script that I run starts with a section like this:

trap 'echo INTERRUPTED!! > /cygdrive/c/int0.txt;exit' 0
trap 'echo INTERRUPTED!! > /cygdrive/c/int1.txt;exit' 1
trap 'echo INTERRUPTED!! > /cygdrive/c/int2.txt;exit' 2
trap 'echo INTERRUPTED!! > /cygdrive/c/int3.txt;exit' 3
trap 'echo INTERRUPTED!! > /cygdrive/c/int4.txt;exit' 4
trap 'echo INTERRUPTED!! > /cygdrive/c/int5.txt;exit' 5
trap 'echo INTERRUPTED!! > /cygdrive/c/int6.txt;exit' 6
trap 'echo INTERRUPTED!! > /cygdrive/c/int7.txt;exit' 7
trap 'echo INTERRUPTED!! > /cygdrive/c/int8.txt;exit' 8

and so on and then runs the long process in the background followed
by:
wait $!

If I run that from a command prompt using "sh my_script
my_script_args",
then I can do a CTRL-C and the script terminates and I get 2 output
files int0.txt and int2.txt as expected.  If I run that process from
eclipse using the ProcessFactory approach, then I don't get any
output
files at all.

Beyond that, I don't have any insight, but I hope that helps.

Thanks,

James



-----Original Message-----
From: cdt-core-dev-admin@xxxxxxxxxxx [mailto:cdt-core-dev-
admin@xxxxxxxxxxx] On Behalf Of Alex Chapiro
Sent: 23 July 2004 19:26
To: cdt-core-dev@xxxxxxxxxxx
Subject: Re: [cdt-core-dev] Problem cancelling a launch

Yes, I know about that. It is much better because TerminatePocess
doesn't terminate child processes. I just cannot use it because we


still


support Windows NT.

Treggiari, Leo wrote:



There are issues with killing child processes on Windows.  I have


used


a Job Object on Windows 2000 & XP - they are not implemented on NT


4.0.


The Job Object allows you to kill the process that you spawn,
along with all of its children.  For a discussion of the problem in
killing a process and its children, see Microsoft System Journal
June
1998, "Q & A, Win32".

Leo

-----Original Message-----
From: cdt-core-dev-admin@xxxxxxxxxxx
[mailto:cdt-core-dev-admin@xxxxxxxxxxx] On Behalf Of Alex Chapiro
Sent: Friday, July 23, 2004 1:52 PM
To: cdt-core-dev@xxxxxxxxxxx
Subject: Re: [cdt-core-dev] Problem cancelling a launch

Actually it definetly sends CTRL-C as you can see it in gdb case. I


just


guess, that second level child process does not get it. I'll test
it.
James Langley wrote:





I can cancel a make, but not during linking.  I suspect that this
is
a


related problem.  It's less noticeable with make because the other
processes that are launched generally don't live very long and so


the


cancel seems very responsive.  If I cancel when the linker is


running


(probably the longest single task) then the cancel only takes
effect
once the linker has terminated.  In the download case, the
download
can


be quite a significant length of time (up to several minutes) so
not
being able to cancel is pretty unpleasant.

As a side note, I've just tried an experiment with the script
where
I


write a text file in the trap handler.  When I run that from the




command




line and use CTRL-C I get a file for trap 0 and trap 2, which is


what I


would expect.  When I do the same thing from eclipse and hit
cancel,
I


don't get any files at all, which suggests that the CTRL-C code


isn't


working in the spawner.  I'll do some more investigation...

James







-----Original Message-----
From: cdt-core-dev-admin@xxxxxxxxxxx [mailto:cdt-core-dev-
admin@xxxxxxxxxxx] On Behalf Of Alex Chapiro
Sent: 23 July 2004 17:46
To: cdt-core-dev@xxxxxxxxxxx
Subject: Re: [cdt-core-dev] Problem cancelling a launch

BTW, are you able to cancel make? Builder should use the same






mechanism.






It is strange for me that nobody complains about build


cancellation.


James Langley wrote:







I've tried using Runtime.exec() to do the same thing and that


means




that






I can cancel successfully, but I don't think that a CTRL-C gets


sent




to






the shell and so there's no opportunity to handle any cleanup.


I'd




like






to use the ProcessFactory approach if possible as I believe that






CTRL-C






is the whole reason that the ProcessFactory approach exists.

Do you use the trap command in your scripts, because if I use
the




trap






command to exit and make sure to run any processes in the


background




in






the script and then wait for them to finish I can kill the
script
successfully at the command prompt.  If I don't do that, then
even
a


CTRL-C at the command prompt doesn't kill the child process.

James

-----Original Message-----
From: cdt-core-dev-admin@xxxxxxxxxxx
[mailto:cdt-core-dev-admin@xxxxxxxxxxx] On Behalf Of Lott,


Jeremiah


Sent: 23 July 2004 16:21
To: cdt-core-dev@xxxxxxxxxxx
Subject: RE: [cdt-core-dev] Problem cancelling a launch

We had similar problem using ProcessFactory in CDT 1.2.0.  We


started


using Runtime.exec(...) in all cases where we didn't explicitly


need




the






extra features provided by ProcessFactory and started getting


better


results.  However, we will still sometimes get the behavior that


the


parent process dies and the UI control returns to the user, but


the


child process continues to run in the background.  These
problems




seem






to happen much more on windows (with Cygwin) than on Linux.

Jeremiah Lott
TimeSys Corporation
-----Original Message-----
From: James Langley [mailto:jlangley@xxxxxxxxxx]
Sent: Friday, July 23, 2004 10:57 AM
To: cdt-core-dev@xxxxxxxxxxx
Subject: [cdt-core-dev] Problem cancelling a launch
Hi,

I'm having some problems with process termination under CDT that
I




hope






someone can help with.  This might be a candidate for a
bugzilla,
but




I






thought I'd ask here first.

As part of our launch process for a remote hardware target, we


need




to






download the elf file to the board.  This is accomplished by a


shell


script which does some processing and then launches an
executable
to


download to the board.  So we have a step in our launch which
runs




the






download script.  If the elf file is large, the download can
take




some






time, so it would be nice to be able to cancel the process.


Here's a


snippet of code from the launch configuration delegate which


should


allow for cancelling:

Process process = exec(runCommandArray,






getEnvironmentProperty(config),






currentWorkingDir);
IProcess downloadProcess = DebugPlugin.newProcess(launch,
process,
renderProcessLabel(getRunLabel()));

int total_work = 0;

while (!downloadProcess.isTerminated())
{
if (monitor.isCanceled())
{
      if (downloadProcess.canTerminate())
            downloadProcess.terminate();
      return false;
}
if (total_work <= 90)
      monitor.worked(10);
try
{
      Thread.sleep(1000);
}
catch (InterruptedException e)
{}
}

The runCommandArray consists of the path for sh, then the name
of
the


script and then the arguments for the script.  The exec command


ends




up






running the following line of code:

ProcessFactory.getFactory().exec(cmdLine, envp,
workingDirectory);
When the script is run from the command line, it can be
cancelled
successfully and it cleans up its child processes.  However,
when
run




from eclipse, the call to terminate() hangs until the download






program






(which was launched by the script) has finished.  From
debugging,
it


looks as though the culprit is the call to:

((SpawnerInputStream)getErrorStream()).close();

in the destroy method of the Spawner.

Sorry for the lengthy description of the problem, but is there


some




part






of the cancel process that I'm missing, or is there some kind of






problem






with the Spawner that means that it doesn't terminate processes
properly?  I'm running on Windows XP and the problem seems to


exist




in






CDT 1.2.1 and 2.0.  If a bugzilla would be more appropriate than
a
discussion in this mailing list, feel free to let me know and
I'll
submit the problem there.

Thanks in advance,


James Langley
Senior Software Engineer
Altera European Technology Centre
Holmers Farm Way
High Wycombe
Bucks HP12 4XF
United Kingdon
http://www.altera.com <http://www.altera.com>






<http://www.altera.com>






.









_______________________________________________
cdt-core-dev mailing list
cdt-core-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/cdt-core-dev






_______________________________________________
cdt-core-dev mailing list
cdt-core-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/cdt-core-dev







_______________________________________________
cdt-core-dev mailing list
cdt-core-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/cdt-core-dev

_______________________________________________
cdt-core-dev mailing list
cdt-core-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/cdt-core-dev





_______________________________________________
cdt-core-dev mailing list
cdt-core-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/cdt-core-dev







Back to the top