Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. System Admin
  4. Std - Handles

Std - Handles

Scheduled Pinned Locked Moved System Admin
question
5 Posts 3 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jens Kreiensiek
    wrote on last edited by
    #1

    Hi All, I'm writing a service, that spawns several new processes. These new procs can either be gui apps or console apps. I redirect the std handles (stdout/stderr/stdin) via anonymous pipes as seen in well known msdn articles. After creating the new processes I wait for all my pipe-handles to become signaled. So far so good. Everything works fine with console apps, but if I start a gui app (e.g. notepad.exe), the pipe handle (stdout) gets signaled and a following ReadFile() blocks forever!. Okay, I tried to check for available data with PeekNamedPipe(). It's return value is always 0 (zero), so I skip the ReadFile(). But now the pipe handle becomes signaled ever and ever again and my cpu is at 100% with peeking the stdout pipe... I'm lost. What does Notepad.exe do with the std - handles? Any hints would be very appreciated!!! Frozen greetings from Germany, Jens :suss:

    L M 2 Replies Last reply
    0
    • J Jens Kreiensiek

      Hi All, I'm writing a service, that spawns several new processes. These new procs can either be gui apps or console apps. I redirect the std handles (stdout/stderr/stdin) via anonymous pipes as seen in well known msdn articles. After creating the new processes I wait for all my pipe-handles to become signaled. So far so good. Everything works fine with console apps, but if I start a gui app (e.g. notepad.exe), the pipe handle (stdout) gets signaled and a following ReadFile() blocks forever!. Okay, I tried to check for available data with PeekNamedPipe(). It's return value is always 0 (zero), so I skip the ReadFile(). But now the pipe handle becomes signaled ever and ever again and my cpu is at 100% with peeking the stdout pipe... I'm lost. What does Notepad.exe do with the std - handles? Any hints would be very appreciated!!! Frozen greetings from Germany, Jens :suss:

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Maybe the problem is that you try to talk with GUI applications by the same way as with console applications. They should be handled by the other way. After creating the process use WaitForInputIdle() to wait for it's initialization. FindWindow, EnumWindows etc. allow to get window handle, after this talk with this window using PostMessage. Check out also windows hooks (SetWindowsHookEx). There is nothing to do with pipes here.

      J 1 Reply Last reply
      0
      • L Lost User

        Maybe the problem is that you try to talk with GUI applications by the same way as with console applications. They should be handled by the other way. After creating the process use WaitForInputIdle() to wait for it's initialization. FindWindow, EnumWindows etc. allow to get window handle, after this talk with this window using PostMessage. Check out also windows hooks (SetWindowsHookEx). There is nothing to do with pipes here.

        J Offline
        J Offline
        Jens Kreiensiek
        wrote on last edited by
        #3

        ...sure, but my problem is the strange behavior. I don't know whether I start a gui- or console application, so I can't differentiate between them. If a gui applicaton doesn't touch the std-handles, why do they behave in such a strange fashion?

        L 1 Reply Last reply
        0
        • J Jens Kreiensiek

          Hi All, I'm writing a service, that spawns several new processes. These new procs can either be gui apps or console apps. I redirect the std handles (stdout/stderr/stdin) via anonymous pipes as seen in well known msdn articles. After creating the new processes I wait for all my pipe-handles to become signaled. So far so good. Everything works fine with console apps, but if I start a gui app (e.g. notepad.exe), the pipe handle (stdout) gets signaled and a following ReadFile() blocks forever!. Okay, I tried to check for available data with PeekNamedPipe(). It's return value is always 0 (zero), so I skip the ReadFile(). But now the pipe handle becomes signaled ever and ever again and my cpu is at 100% with peeking the stdout pipe... I'm lost. What does Notepad.exe do with the std - handles? Any hints would be very appreciated!!! Frozen greetings from Germany, Jens :suss:

          M Offline
          M Offline
          Mike Nordell
          wrote on last edited by
          #4

          What about CreateProcess and waiting on the process handle? Actually, from your description I'm not entirely sure what you really want to do. /Mike

          1 Reply Last reply
          0
          • J Jens Kreiensiek

            ...sure, but my problem is the strange behavior. I don't know whether I start a gui- or console application, so I can't differentiate between them. If a gui applicaton doesn't touch the std-handles, why do they behave in such a strange fashion?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Maybe function IsGUIThread may help you.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups