Jump to content

Search the Community

Showing results for tags 'createprocess'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Delphi Questions and Answers
    • Algorithms, Data Structures and Class Design
    • VCL
    • FMX
    • RTL and Delphi Object Pascal
    • Databases
    • Network, Cloud and Web
    • Windows API
    • Cross-platform
    • Delphi IDE and APIs
    • General Help
    • Delphi Third-Party
  • C++Builder Questions and Answers
    • General Help
  • General Discussions
    • Embarcadero Lounge
    • Tips / Blogs / Tutorials / Videos
    • Job Opportunities / Coder for Hire
    • I made this
  • Software Development
    • Project Planning and -Management
    • Software Testing and Quality Assurance
  • Community
    • Community Management

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Delphi-Version

Found 1 result

  1. Der schöne Günther

    CTRL+C to a console app vs. TerminateProcess(..)

    I have a stupid question on how to "gracefully" terminate a Windows console application. I am not very familiar with how processes are established, how parent/child relationships are handled, consoles, all that. I might be missing basics. What I am doing: I have a central application with a VCL interface It uses CreateProcess(..) to invisibly spawn some console applications in the background Some are kept running 24/7, some are just started on demand, crunch some data, then terminate These console applications get their stdIn, stdOut and stdErr pipes redirected to some pipes I created in my central applications, so I can easily process their output, and control them (if they get controlled from stdIn). So far, everything worked like a breeze My issue now: I am now integrating another console application that just runs 24/7 and has no way of gracefully shutting it down It will only end on either pressing CTRL+C on a regular terminal, or by sending it a CTRL_BREAK_EVENT from my central application by using GenerateConsoleCtrlEvent. I know that Windows will "clean up" after the process has ended, but I am not sure if this way of shutting the process down is still a bit too "rude" My question: The documentation of the GenerateConsoleCtrlEvent function states "All console processes have a default handler function that calls the ExitProcess function." The documentation on ExitProcess gets into more detail of what it actually does, but I have a hard time understanding the implications. After sending the CTRL_BREAK_EVENT to the console application, my application will still give it a few hundred milliseconds to power down until it will resort to TerminateProcess but never has to, because the console application will finish within less than 5 ms. I am just unsure whether I am doing it right or maybe there is a better way of "gracefully" shutting down a console application that does not handle CTRL+C at all.
×