tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

process_watcher.h (1647B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
      4 // Use of this source code is governed by a BSD-style license that can be
      5 // found in the LICENSE file.
      6 
      7 #ifndef CHROME_COMMON_PROCESS_WATCHER_H_
      8 #define CHROME_COMMON_PROCESS_WATCHER_H_
      9 
     10 #include "base/basictypes.h"
     11 #include "base/process_util.h"
     12 #ifdef XP_UNIX
     13 #  include "mozilla/UniquePtrExtensions.h"
     14 #endif
     15 
     16 class ProcessWatcher {
     17 public:
     18 #ifdef NS_FREE_PERMANENT_DATA
     19  static constexpr bool kDefaultForce = false;
     20 #else
     21  static constexpr bool kDefaultForce = true;
     22 #endif
     23 
     24  // This method ensures that the specified process eventually terminates, and
     25  // then it closes the given process handle.
     26  //
     27  // It assumes that the process has already been signalled to exit, and it
     28  // begins by waiting a small amount of time for it to exit.  If the process
     29  // does not appear to have exited, then this function starts to become
     30  // aggressive about ensuring that the process terminates.
     31  //
     32  // This method does not block the calling thread.
     33  //
     34  // NOTE: The process handle must have been opened with the PROCESS_TERMINATE
     35  // and SYNCHRONIZE permissions.
     36  //
     37  static void EnsureProcessTerminated(base::ProcessHandle process_handle,
     38                                      bool force = kDefaultForce);
     39 
     40 #ifdef XP_UNIX
     41  static mozilla::UniqueFileHandle GetSignalPipe();
     42 #endif
     43 
     44 private:
     45  // Do not instantiate this class.
     46  ProcessWatcher();
     47 
     48  DISALLOW_COPY_AND_ASSIGN(ProcessWatcher);
     49 };
     50 
     51 #endif  // CHROME_COMMON_PROCESS_WATCHER_H_