summaryrefslogtreecommitdiff
path: root/NonInheritingProcess.hpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2020-11-16 21:54:50 +0100
committerChristoph Berg <myon@debian.org>2020-11-16 21:54:50 +0100
commit77922fa33547ce24535f2e514c9a112dcb496f18 (patch)
tree9f82b0ee01281b315f43a4c60d678927b4c6ca59 /NonInheritingProcess.hpp
parent7aa3c56b01768ba7d38fccedc17b30a4046b3fbb (diff)
New upstream version 2.3.0~rc2+repackupstream/2.3.0_rc2+repack
Diffstat (limited to 'NonInheritingProcess.hpp')
-rw-r--r--NonInheritingProcess.hpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/NonInheritingProcess.hpp b/NonInheritingProcess.hpp
new file mode 100644
index 00000000..c38d41ed
--- /dev/null
+++ b/NonInheritingProcess.hpp
@@ -0,0 +1,35 @@
+#ifndef NON_INHERITING_PROCESS_HPP__
+#define NON_INHERITING_PROCESS_HPP__
+
+#include <QProcess>
+#include "pimpl_h.hpp"
+
+class QObject;
+
+//
+// class NonInheritingProcess - Manage a process without it inheriting
+// all inheritable handles
+//
+// On MS Windows QProcess creates sub-processes which inherit all
+// inheritable handles, and handles on Windows are inheritable by
+// default. This can cause the lifetime of objects to be unexpectedly
+// extended, which in turn can cause unexpected errors. The motivation
+// for this class was implementing log file rotation using the Boost
+// log library. The current log file's handle gets inherited by any
+// long running sub-process started by QProcess and that causes a
+// sharing violation when attempting to rename the log file on
+// rotation, even though the log library closes the current log file
+// before trying to rename it.
+//
+class NonInheritingProcess
+ : public QProcess
+{
+public:
+ NonInheritingProcess (QObject * parent = nullptr);
+ ~NonInheritingProcess ();
+
+private:
+ class impl;
+ pimpl<impl> m_;
+};
+#endif