• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

You know how you can kill processes in Unix, what about Win?

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    You know how you can kill processes in Unix, what about Win?

    How do you kill processes in Windows? Task Manager hides them! Is there a better way in DOS?

    #2
    stuff

    install Cygwin and you will have unix command "kill" - it may be better than task manager but ultimately Windows is weak at killing processes dead - kill -9 always worked for me in Unix

    Comment


      #3
      Re: stuff

      One thing I always found odd about the way some people did things in Unix was poor use of processes. Place I used to work had some very flaky in-house software.

      Among the numerous bugs, whenever you used one particular option on the menu it launched a new process.Only discovered that when I ran out of memory and found umpteen processes running.

      Comment


        #4
        Re: stuff

        I normally find installing any new app in windows does the trick - usually kills off most of the stuff that used to work and frequently (for reason best known to the boy god himself) completely screws up networking so you have to bin it all and redefine it.

        Comment


          #5
          Re: You know how you can kill processes in Unix, what about

          DWORD WINAPI CLaunch::LaunchAndWait( LPVOID pParam )
          {
          //&nbsp &nbsp &nbsp &nbsp UC_FILENOTFOUND
          //&nbsp &nbsp &nbsp &nbsp UC_TIMEOUT
          // UC_SHUTDOWN&nbsp &nbsp &nbsp &nbsp
          // UC_SUCCESS
          // UC_FAILURE&nbsp &nbsp &nbsp &nbsp
          &nbsp &nbsp &nbsp &nbsp
          &nbsp &nbsp &nbsp &nbsp LPTHREADINFO pThreadInfo = (LPTHREADINFO)pParam;
          &nbsp &nbsp &nbsp &nbsp PROCESS_INFORMATION&nbsp &nbsp &nbsp &nbsp stProcessInfo;

          &nbsp &nbsp &nbsp &nbsp if ( LaunchApplication( pThreadInfo, &stProcessInfo ) )
          &nbsp &nbsp &nbsp &nbsp {
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // Need to store thread to list to prevent memory leaks with CWinThread object.
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // If our main app is requested to terminate
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // before this thread terminates, then we need to terminate this thread first.

          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // Wait for either the process to terminate or the event to be signalled.
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // If the event is signalled, then that indicates the main application
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // is terminating and all open threads need to terminate also.

          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp HANDLE hThreads[2];
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp hThreads[0] = pThreadInfo->hTermMonitorThreads;
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp hThreads[1] = stProcessInfo.hProcess;
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp DWORD dwWait = pThreadInfo->m_dwWait ;
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp // wait for application to terminate or event to be signalled
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp DWORD dwIndex = WaitForMultipleObjects( 2, hThreads, FALSE, dwWait ) ;
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp g_bStatus |= 0x01 ; /* Turn On The Continue Flag */
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp if ( dwIndex != WAIT_TIMEOUT )&nbsp &nbsp &nbsp &nbsp
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp {
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp if ( dwIndex == 0 )
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp {
          /* Force Close Down */
          HANDLE hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, stProcessInfo.dwProcessId ) ;
          TerminateProcess( hProcess, 99 ) ;
          CloseHandle( hProcess ) ;
          &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp g_bStatus = 0 ;


          A case of write it yourself or find some complete jobbie
          written by macroshaft that comes with C++ to kill threads
          and things.

          If I was like the smart asses on this forum I would just say
          call TerminateProcess .....

          D.

          Comment

          Working...
          X