On Windows, how does console window ownership work?

前端 未结 6 721
無奈伤痛
無奈伤痛 2021-01-13 01:05

When a console application is started from another console application, how does console ownership work?

I see four possibilities:

  1. The second applicati
6条回答
  •  广开言路
    2021-01-13 01:53

    CMD 'owns' the console. When it creates a process for an app, that app inherits handles to the console. It can read and write those. When the process goes away, CMD continues ownership.

    Note: I'm not entirely sure that 'ownership' is the right word here. Windows will close the Console when CMD exits, but that may be a simple setting.

提交回复
热议问题