Improve --debug output to show pid of processes that are started and stopped
authorJoey Hess <joeyh@joeyh.name>
Thu, 24 Sep 2020 16:39:57 +0000 (12:39 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 24 Sep 2020 16:39:57 +0000 (12:39 -0400)
commit68f9766544c62d07d6bbcf8fda31ab3851934a90
treee2a3db088336fdc31fcdebd50b5922d973c89fd1
parent661fdbf51eb94ccfc664f930548c4e89ea5e5ff6
Improve --debug output to show pid of processes that are started and stopped

getPid returns Nothing if the process has already been stopped, and in that
case, the pid will not be displayed. I think that would only happen if
waitForProcess or similar gets called more than once on the same process
handle though.

getPid on unix has an overhead of only a MVar read. On Windows it needs to
make a syscall, so will be probably more expensive. While the added expense
happens even when debug logging is disabled, it should be small enough
compared with the overhead of starting a process that it's not a problem.

(It does occur to me that a debugM that took an IO String could only run it
when debugging is really enabled, which would improve performance. It does
not seem possible to use the current hslogger interface to do that though;
it does not expose the information that would be needed.)
CHANGELOG
Utility/Process.hs
doc/todo/report_PID___40__and_may_be_failure_details__63____41___in___34__process_done__34___debug_messages/comment_1_3b069234f20378fc231802c594eb213d._comment [new file with mode: 0644]