The OP wrote, "I am looking for a "clean" way to terminate processes I've created on both Linux and Windows." ... The PID returned from fork is apparently useless. When I kill 1 $child_pid, the main process complains Terminating
Did you test your "solution" against his setting?

First of all, I don't have access to Windows 11 right now, so I cannot test it. So, only he can test the solution that I wrote. Btw this works fine on Windows XP.

Secondly, if you are not sure whether this solution works or not on Windows 11, why do you downvote my answer? If you have tested it and know for a fact that it does not work, then you may downvote it. Otherwise, you're abusing the system by just downvoting answers that you know nothing about whether they work or not. (Yes, I have tested my answer on Windows XP, Windows 7, and Windows 10. I have found that most things that work on XP also work on later versions, but this is not true the other way around. If I was using Windows 11, and I had a solution to something, it might not work on Windows XP, because that's just how Microsoft is...)


In reply to Re^3: How to portably stop processes? by harangzsolt33
in thread How to portably stop processes? by haj

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.