File: NonInheritingProcess.hpp

package info (click to toggle)
wsjtx 2.3.0%2Brepack-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 63,524 kB
  • sloc: cpp: 59,051; f90: 34,130; python: 27,241; ansic: 11,205; fortran: 2,051; sh: 132; makefile: 109
file content (35 lines) | stat: -rw-r--r-- 1,131 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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