ncbi_os_unix.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:3k
源码类别:

生物技术

开发平台:

C/C++

  1. /*
  2.  * ===========================================================================
  3.  * PRODUCTION $Log: ncbi_os_unix.hpp,v $
  4.  * PRODUCTION Revision 1000.0  2003/10/29 15:02:06  gouriano
  5.  * PRODUCTION PRODUCTION: IMPORTED [ORIGINAL] Dev-tree R1.1
  6.  * PRODUCTION
  7.  * ===========================================================================
  8.  */
  9. #ifndef CORELIB___NCBI_OS_UNIX__HPP
  10. #define CORELIB___NCBI_OS_UNIX__HPP
  11. /*  $Id: ncbi_os_unix.hpp,v 1000.0 2003/10/29 15:02:06 gouriano Exp $
  12.  * ===========================================================================
  13.  *
  14.  *                            PUBLIC DOMAIN NOTICE
  15.  *               National Center for Biotechnology Information
  16.  *
  17.  *  This software/database is a "United States Government Work" under the
  18.  *  terms of the United States Copyright Act.  It was written as part of
  19.  *  the author's official duties as a United States Government employee and
  20.  *  thus cannot be copyrighted.  This software/database is freely available
  21.  *  to the public for use. The National Library of Medicine and the U.S.
  22.  *  Government have not placed any restriction on its use or reproduction.
  23.  *
  24.  *  Although all reasonable efforts have been taken to ensure the accuracy
  25.  *  and reliability of the software and data, the NLM and the U.S.
  26.  *  Government do not and cannot warrant the performance or results that
  27.  *  may be obtained by using this software or data. The NLM and the U.S.
  28.  *  Government disclaim all warranties, express or implied, including
  29.  *  warranties of performance, merchantability or fitness for any particular
  30.  *  purpose.
  31.  *
  32.  *  Please cite the author in any work or product based on this material.
  33.  *
  34.  * ===========================================================================
  35.  *
  36.  * Author:  Anton Lavrentiev
  37.  *
  38.  */
  39. /// @file ncbi_os_unix.hpp
  40. /// UNIX-specifics
  41. ///
  42. #include <corelib/ncbistl.hpp>
  43. #if !defined(NCBI_OS_UNIX)
  44. #  error "ncbi_os_unix.hpp must be used on UNIX platforms only"
  45. #endif
  46. #include <unistd.h>
  47. BEGIN_NCBI_SCOPE
  48. /// Daemonization flags
  49. enum FDaemonFlags {
  50.     fDaemon_DontChroot = 1,
  51.     fDaemon_KeepStdin  = 2,
  52.     fDaemon_KeepStdout = 4
  53. };
  54. /// Bit-wise OR of FDaemonFlags @sa FDaemonFlags
  55. typedef unsigned int TDaemonFlags;
  56. /// Go daemon.
  57. ///
  58. /// Return true in the daemon thread.
  59. /// Return false on error (no daemon created), errno can be used to analyze.
  60. /// Reopen stderr in daemon thread if logfile specified as non-NULL,
  61. /// otherwise stderr is closed in the daemon thread.
  62. /// NB: Always check stderr for errors of failed redirection!
  63. ///
  64. /// Unless instructed by flags parameter, the daemon thread has its
  65. /// stdin and stdout closed, and current directory changed to root (/).
  66. /// If kept open, stdin and stdout are both redirected to /dev/null.
  67. ///
  68. /// Note that this call is somewhat destructive and may not be able
  69. /// to restore the process that called it to a state before the call
  70. /// in case of an error.  So that calling process can find std file
  71. /// pointers (and sometimes descriptors) screwed up.
  72. bool Daemonize(const char* logfile = 0, TDaemonFlags flags = 0);
  73. END_NCBI_SCOPE
  74. /* --------------------------------------------------------------------------
  75.  * $Log: ncbi_os_unix.hpp,v $
  76.  * Revision 1000.0  2003/10/29 15:02:06  gouriano
  77.  * PRODUCTION: IMPORTED [ORIGINAL] Dev-tree R1.1
  78.  *
  79.  * Revision 1.1  2003/09/30 20:52:56  lavr
  80.  * Initial revision
  81.  *
  82.  * ==========================================================================
  83.  */
  84. #endif  /* CORELIB___NCBI_OS_UNIX__HPP */