public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) - not closing child process
@ 2001-08-13  8:08 Trenton D. Adams
  2001-08-13  9:30 ` Julian Smart
  0 siblings, 1 reply; 7+ messages in thread
From: Trenton D. Adams @ 2001-08-13  8:08 UTC (permalink / raw)
  To: 'eCos Disuss'

Start building a project and then try and cancel.  The config tool
doesn't kill make.exe cc1.exe or arm-elf-gcc.exe.

I have some process killing code that I made for windows at home if the
config tool doesn't have it already.  If you want it, let me know.  You
should have the process ID already anyhow when the processes are
spawned, but for some weird reason the config tool might not be able to
close the child process.  If that happens my code should work.

Trenton D. Adams
Extreme Engineering
#17, 6025 - 12 St. SE
Calgary, Alberta, Canada
T2H 2K1

Phone: 403 640 9494 ext-208
Fax: 403 640 9599

http://www.extremeeng.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) - not closing child process
  2001-08-13  8:08 [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) - not closing child process Trenton D. Adams
@ 2001-08-13  9:30 ` Julian Smart
  2001-08-13  9:48   ` Trenton D. Adams
  2001-08-13 10:44   ` [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) - notclosing " Jonathan Larmour
  0 siblings, 2 replies; 7+ messages in thread
From: Julian Smart @ 2001-08-13  9:30 UTC (permalink / raw)
  To: Trenton D. Adams, ecos-discuss

At 09:08 AM 8/13/01 -0600, you wrote:
>Start building a project and then try and cancel.  The config tool
>doesn't kill make.exe cc1.exe or arm-elf-gcc.exe.
>
>I have some process killing code that I made for windows at home if the
>config tool doesn't have it already.  If you want it, let me know.  You
>should have the process ID already anyhow when the processes are
>spawned, but for some weird reason the config tool might not be able to
>close the child process.  If that happens my code should work.

Thanks -- there was some child-process code in the original CT which I 
should use but I'd also be interested to see your code in case it's easier 
to understand :-)

Julian
--
Red Hat UK Ltd, Unit 200 Rustat House, 62 Clifton Road, Cambridge, UK. CB1 
7EG Tel: +44 (1223) 271063

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) - not  closing child process
  2001-08-13  9:30 ` Julian Smart
@ 2001-08-13  9:48   ` Trenton D. Adams
  2001-08-13 10:44   ` [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) - notclosing " Jonathan Larmour
  1 sibling, 0 replies; 7+ messages in thread
From: Trenton D. Adams @ 2001-08-13  9:48 UTC (permalink / raw)
  To: 'Julian Smart', ecos-discuss

I forgot that I brought all my own code to work for reference material.

I made a screen saver killer one time and that's why I made this code!
:)

All documentation for these functions can of course be found in the MSDN
DVD/CD or the website at http://msdn.microsoft.com

You should open the kernel32.dll manually for getting a pointer to the
CreateToolhelp32Snapshot (), Process32First (), Process32Next (), etc.
Why?  Because it won't work on Windows NT/2000 if you don't.  The code
below works fine on Windows 98 but I never got around to using
LoadLibrary() and GetProcAddress () to get the pointers.  If you need
that as well, I can post some code for it.

Look up the documentation on PROCESSENTRY32 because I only fill in the
extension part because I'm killing all SCR programs.

I created this in a rush so I didn't have time to comment it.  The
program was only 135 lines anyhow so it's not really worth commenting!
:)  Besides, I think it's fairly straight forward code.


p.s.
TerminateProcess () should only be called when you can't close the
process normally.  It can cause memory leaks and resource leaks because
it doesn't allow the program to deallocate it's memory or handles.

------------------BEGIN KILL PROC CODE------------------
    HANDLE snapShot;
    PROCESSENTRY32 procEntry;


   snapShot = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0);
   returnValue = (int)snapShot;
   if (returnValue == -1)
   {
      MessageBoxEx (hwnd, "Failed to Get a Snap Shot of the system",
"Failure",
         MB_OK | MB_ICONINFORMATION, 0);
   }

   procEntry.dwSize = sizeof (PROCESSENTRY32);
   if (!Process32First (snapShot, &procEntry))
      MessageBoxEx (hwnd, "Failed to get first Process Information",
"Failure",
         MB_OK | MB_ICONINFORMATION, 0);


   if (strstr (procEntry.szExeFile, ".SCR") != NULL ||
         strstr (procEntry.szExeFile, ".scr") != NULL)
   {
      processID = OpenProcess (PROCESS_TERMINATE, FALSE,
procEntry.th32ProcessID);
      if (processID != NULL)
      {
         returnValue = TerminateProcess (processID, 0xFFFFFFFF);
         if (returnValue)
            WaitForSingleObject(processID, INFINITE);
         else
            MessageBoxEx (hwnd, "Failed to Terminate", "Failure",
               MB_OK | MB_ICONINFORMATION, 0);
         CloseHandle (processID);
      }
      else
         MessageBoxEx (hwnd, "Failed to open Process", "Failure",
            MB_OK | MB_ICONINFORMATION, 0);
   }

   while (Process32Next (snapShot, &procEntry))
   {
      if (strstr (procEntry.szExeFile, ".SCR") != NULL ||
         strstr (procEntry.szExeFile, ".scr") != NULL)
      {
         processID = OpenProcess (PROCESS_TERMINATE, FALSE,
procEntry.th32ProcessID);
         if (processID != NULL)
         {
            returnValue = TerminateProcess (processID, 0xFFFFFFFF);
            if (returnValue)
               WaitForSingleObject(processID, INFINITE);
            else
               MessageBoxEx (hwnd, "Failed to Terminate", "Failure",
                  MB_OK | MB_ICONINFORMATION, 0);
            CloseHandle (processID);
         }
         else
            MessageBoxEx (hwnd, "Failed to open Process", "Failure",
               MB_OK | MB_ICONINFORMATION, 0);
      }
   }
   CloseHandle (snapShot);
-------------------END KILL PROC CODE-------------------


-----Original Message-----
From: ecos-discuss-owner@sources.redhat.com
[ mailto:ecos-discuss-owner@sources.redhat.com ] On Behalf Of Julian Smart
Sent: Monday, August 13, 2001 10:36 AM
To: Trenton D. Adams; ecos-discuss@sourceware.cygnus.com
Subject: Re: [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) - not
closing child process


At 09:08 AM 8/13/01 -0600, you wrote:
>Start building a project and then try and cancel.  The config tool
>doesn't kill make.exe cc1.exe or arm-elf-gcc.exe.
>
>I have some process killing code that I made for windows at home if the
>config tool doesn't have it already.  If you want it, let me know.  You
>should have the process ID already anyhow when the processes are
>spawned, but for some weird reason the config tool might not be able to
>close the child process.  If that happens my code should work.

Thanks -- there was some child-process code in the original CT which I 
should use but I'd also be interested to see your code in case it's
easier 
to understand :-)

Julian
--
Red Hat UK Ltd, Unit 200 Rustat House, 62 Clifton Road, Cambridge, UK.
CB1 
7EG Tel: +44 (1223) 271063

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) - notclosing child process
  2001-08-13  9:30 ` Julian Smart
  2001-08-13  9:48   ` Trenton D. Adams
@ 2001-08-13 10:44   ` Jonathan Larmour
  2001-08-13 11:27     ` Trenton D. Adams
                       ` (2 more replies)
  1 sibling, 3 replies; 7+ messages in thread
From: Jonathan Larmour @ 2001-08-13 10:44 UTC (permalink / raw)
  To: Julian Smart; +Cc: Trenton D. Adams, ecos-discuss

Julian Smart wrote:
> 
> At 09:08 AM 8/13/01 -0600, you wrote:
> >Start building a project and then try and cancel.  The config tool
> >doesn't kill make.exe cc1.exe or arm-elf-gcc.exe.
> >
> >I have some process killing code that I made for windows at home if the
> >config tool doesn't have it already.  If you want it, let me know.  You
> >should have the process ID already anyhow when the processes are
> >spawned, but for some weird reason the config tool might not be able to
> >close the child process.  If that happens my code should work.
> 
> Thanks -- there was some child-process code in the original CT which I
> should use but I'd also be interested to see your code in case it's easier
> to understand :-)

If it's MSDN code we can't use it though....

Also, these are cygwin processes, so they should be killed in a "cygwin"
way so cygwin can do it's own correct cleanup. Is the new config tool
linking with the cygwin dll now? If so, perhaps using the cygwin kill
should be reliable now. When the original CT came out, cygwin kill was
unreliable, leading to extra complexity in the code.

Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223) 271062
Maybe this world is another planet's Hell -Aldous Huxley || Opinions==mine

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) - notclosing child  process
  2001-08-13 10:44   ` [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) - notclosing " Jonathan Larmour
@ 2001-08-13 11:27     ` Trenton D. Adams
  2001-08-14 10:18     ` Trenton D. Adams
  2001-08-15  6:12     ` Bart Veer
  2 siblings, 0 replies; 7+ messages in thread
From: Trenton D. Adams @ 2001-08-13 11:27 UTC (permalink / raw)
  To: 'Jonathan Larmour', 'Julian Smart'; +Cc: ecos-discuss

No, as I said.  The code is mine.  The documentation of the functions is
not code, it just tells you what the parameters are and stuff like that.
Like a man page does.

Anyhow, if cygwin can't kill it properly, feel free to use mine.  I did
this at home on my own time and not working for any company, and was
never paid for it so it is Mine (tm).

-----Original Message-----
From: jlarmour@cambridge.redhat.com
[ mailto:jlarmour@cambridge.redhat.com ] On Behalf Of Jonathan Larmour
Sent: Monday, August 13, 2001 11:44 AM
To: Julian Smart
Cc: Trenton D. Adams; ecos-discuss@sourceware.cygnus.com
Subject: Re: [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) -
notclosing child process


Julian Smart wrote:
> 
> At 09:08 AM 8/13/01 -0600, you wrote:
> >Start building a project and then try and cancel.  The config tool
> >doesn't kill make.exe cc1.exe or arm-elf-gcc.exe.
> >
> >I have some process killing code that I made for windows at home if
the
> >config tool doesn't have it already.  If you want it, let me know.
You
> >should have the process ID already anyhow when the processes are
> >spawned, but for some weird reason the config tool might not be able
to
> >close the child process.  If that happens my code should work.
> 
> Thanks -- there was some child-process code in the original CT which I
> should use but I'd also be interested to see your code in case it's
easier
> to understand :-)

If it's MSDN code we can't use it though....

Also, these are cygwin processes, so they should be killed in a "cygwin"
way so cygwin can do it's own correct cleanup. Is the new config tool
linking with the cygwin dll now? If so, perhaps using the cygwin kill
should be reliable now. When the original CT came out, cygwin kill was
unreliable, leading to extra complexity in the code.

Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223)
271062
Maybe this world is another planet's Hell -Aldous Huxley ||
Opinions==mine

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) - notclosing child  process
  2001-08-13 10:44   ` [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) - notclosing " Jonathan Larmour
  2001-08-13 11:27     ` Trenton D. Adams
@ 2001-08-14 10:18     ` Trenton D. Adams
  2001-08-15  6:12     ` Bart Veer
  2 siblings, 0 replies; 7+ messages in thread
From: Trenton D. Adams @ 2001-08-14 10:18 UTC (permalink / raw)
  To: 'Jonathan Larmour', 'Julian Smart'; +Cc: ecos-discuss

That cygwin kill must not be working.  I run a cygwin shell and when gdb
locks up I have to close the shell because Ctrl-C or Ctrl-Z don't work.
cygwin does not kill the background arm-elf-gdb.exe.  So, it would
appear that the kill for cygwin is just as buggy as before.

-----Original Message-----
From: ecos-discuss-owner@sources.redhat.com
[ mailto:ecos-discuss-owner@sources.redhat.com ] On Behalf Of Jonathan
Larmour
Sent: Monday, August 13, 2001 11:44 AM
To: Julian Smart
Cc: Trenton D. Adams; ecos-discuss@sourceware.cygnus.com
Subject: Re: [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) -
notclosing child process


Julian Smart wrote:
> 
> At 09:08 AM 8/13/01 -0600, you wrote:
> >Start building a project and then try and cancel.  The config tool
> >doesn't kill make.exe cc1.exe or arm-elf-gcc.exe.
> >
> >I have some process killing code that I made for windows at home if
the
> >config tool doesn't have it already.  If you want it, let me know.
You
> >should have the process ID already anyhow when the processes are
> >spawned, but for some weird reason the config tool might not be able
to
> >close the child process.  If that happens my code should work.
> 
> Thanks -- there was some child-process code in the original CT which I
> should use but I'd also be interested to see your code in case it's
easier
> to understand :-)

If it's MSDN code we can't use it though....

Also, these are cygwin processes, so they should be killed in a "cygwin"
way so cygwin can do it's own correct cleanup. Is the new config tool
linking with the cygwin dll now? If so, perhaps using the cygwin kill
should be reliable now. When the original CT came out, cygwin kill was
unreliable, leading to extra complexity in the code.

Jifl
-- 
Red Hat, Rustat House, Clifton Road, Cambridge, UK. Tel: +44 (1223)
271062
Maybe this world is another planet's Hell -Aldous Huxley ||
Opinions==mine

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) - notclosing child process
  2001-08-13 10:44   ` [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) - notclosing " Jonathan Larmour
  2001-08-13 11:27     ` Trenton D. Adams
  2001-08-14 10:18     ` Trenton D. Adams
@ 2001-08-15  6:12     ` Bart Veer
  2 siblings, 0 replies; 7+ messages in thread
From: Bart Veer @ 2001-08-15  6:12 UTC (permalink / raw)
  To: jlarmour; +Cc: julians, ecos-discuss

>>>>> "Jifl" == Jonathan Larmour <jlarmour@redhat.com> writes:

    Jifl> Julian Smart wrote:
    >> 
    >> At 09:08 AM 8/13/01 -0600, you wrote:
    >> >Start building a project and then try and cancel.  The config tool
    >> >doesn't kill make.exe cc1.exe or arm-elf-gcc.exe.
    >> >
    >> >I have some process killing code that I made for windows at
    >> >home if the config tool doesn't have it already. If you want
    >> >it, let me know. You should have the process ID already anyhow
    >> >when the processes are spawned, but for some weird reason the
    >> >config tool might not be able to close the child process. If
    >> >that happens my code should work.
    >> 
    >> Thanks -- there was some child-process code in the original CT
    >> which I should use but I'd also be interested to see your code
    >> in case it's easier to understand :-)

    Jifl> If it's MSDN code we can't use it though....

    Jifl> Also, these are cygwin processes, so they should be killed
    Jifl> in a "cygwin" way so cygwin can do it's own correct cleanup.
    Jifl> Is the new config tool linking with the cygwin dll now? If
    Jifl> so, perhaps using the cygwin kill should be reliable now.
    Jifl> When the original CT came out, cygwin kill was unreliable,
    Jifl> leading to extra complexity in the code.

There have been numerous problems killing cygwin apps from the config
tool and elsewhere over the years. The details depend on which version
of cygwin you are using, and on the exact version of Windows - NT4
and 2000 tend to be better behaved than W98.

Using Windows calls to kill of a cygwin process has proved a bad idea
on occasion: usually it worked fine, but occasionally there would be
some problems in the shared state managed by the cygwin dll and
afterwards other cygwin applications would run into problems. The
exact details were never tracked down. I do not know if current cygwin
is affected.

The "correct" way to kill off cygwin processes is to use the cygwin
kill command, or the equivalent kill() call if the parent process is
linked with cygwin. Going behind cygwin's back is just asking for
trouble. If kill does not work reliably then it indicates a problem in
cygwin and the way it interacts with the underlying OS, and this
problem should be tracked down and fixed. After all, cygwin is open
source. A good first step would be a reproducible test case...

Bart

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2001-08-15  6:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-13  8:08 [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) - not closing child process Trenton D. Adams
2001-08-13  9:30 ` Julian Smart
2001-08-13  9:48   ` Trenton D. Adams
2001-08-13 10:44   ` [ECOS] GUI Config tool 2.04 bug (REPRODUCEABLE) - notclosing " Jonathan Larmour
2001-08-13 11:27     ` Trenton D. Adams
2001-08-14 10:18     ` Trenton D. Adams
2001-08-15  6:12     ` Bart Veer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).