* addunused: Don't check .gitignores when adding files.
* Improve the "Try making some of these repositories available"
message, with some hints for the user for what to do.
+ * Improve --debug output to show pid of processes that are started and
+ stopped.
-- Joey Hess <id@joeyh.name> Mon, 14 Sep 2020 18:34:37 -0400
-- | Wrapper around 'System.Process.createProcess' that does debug logging.
createProcess :: CreateProcess -> IO (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle)
createProcess p = do
- debugProcess p
- Utility.Process.Shim.createProcess p
+ r@(_, _, _, h) <- Utility.Process.Shim.createProcess p
+ debugProcess p h
+ return r
-- | Wrapper around 'System.Process.withCreateProcess' that does debug logging.
withCreateProcess :: CreateProcess -> (Maybe Handle -> Maybe Handle -> Maybe Handle -> ProcessHandle -> IO a) -> IO a
(\(m_in, m_out, m_err, ph) -> action m_in m_out m_err ph)
-- | Debugging trace for a CreateProcess.
-debugProcess :: CreateProcess -> IO ()
-debugProcess p = debugM "Utility.Process" $ unwords
- [ action ++ ":"
- , showCmd p
- ]
+debugProcess :: CreateProcess -> ProcessHandle -> IO ()
+debugProcess p h = do
+ pid <- getPid h
+ debugM "Utility.Process" $ unwords
+ [ describePid pid
+ , action ++ ":"
+ , showCmd p
+ ]
where
action
| piped (std_in p) && piped (std_out p) = "chat"
piped Inherit = False
piped _ = True
+describePid :: Maybe Utility.Process.Shim.Pid -> String
+describePid Nothing = "process"
+describePid (Just p) = "process [" ++ show p ++ "]"
+
-- | Wrapper around 'System.Process.waitForProcess' that does debug logging.
waitForProcess :: ProcessHandle -> IO ExitCode
waitForProcess h = do
+ -- Have to get pid before waiting, which closes the ProcessHandle.
+ pid <- getPid h
r <- Utility.Process.Shim.waitForProcess h
- debugM "Utility.Process" ("process done " ++ show r)
+ debugM "Utility.Process" (describePid pid ++ " done " ++ show r)
return r
cleanupProcess :: (Maybe Handle, Maybe Handle, Maybe Handle, ProcessHandle) -> IO ()
--- /dev/null
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 1"""
+ date="2020-09-24T16:32:14Z"
+ content="""
+I've added the pid.
+
+This happens at a layer that only knows the process exited, not what it was
+used for. Of course if we know the process in question the higher layer
+that uses it could be made to log something more informative, if
+the nonzero exit is really unexpected.
+"""]]