OSDN Git Service

Change use of BOOL, TRUE, FALSE to bool, true, false, as appropriate,
authorcgf <cgf>
Sun, 7 Dec 2003 22:37:11 +0000 (22:37 +0000)
committercgf <cgf>
Sun, 7 Dec 2003 22:37:11 +0000 (22:37 +0000)
throughout.
* tty.cc (tty::common_init): Remove call to SetKernelObjectSecurity and edit
some comments.
* cygheap.h (init_cygheap::ctty): Add new element.
* devices.in (device::parse): Remove special handling for /dev/tty.
* devices.cc: Regenerate.
* dtable.cc (build_fh_pc): Don't reset /dev/tty device.  Let the device opener
do that.
* fhandler_termios.cc (tty_min::set_ctty): Redefine to _pinfo class.
* fhandler_tty.cc (fhandler_tty_common::set_close_on_exec): Avoid setting
noninherit flag for ctty.
* tty.h: Move BOOLs to bools.
(tty_min::set_ctty): Redeclare to _pinfo class.
* pinfo.cc (_pinfo::set_ctty): Define new function based on tty_min::set_ctty.
Change first argument from tty number to tty_min class.
* pinfo.h (_pinfo::set_ctty): Declare.
* fhandler_console.cc (fhandler_console::get_tty_stuff): Reflect move of
set_ctty to _pinfo class.
* fhandler_tty.cc (fhandler_tty_slave::open): Treat FH_TTY specially.  Use
saved cygheap value if it exists.  Otherwise convert to real device and save on
first time open.
(fhandler_tty_common::dup): Potentially set controlling tty if duping a slave
tty.
* syscalls.cc (setsid): Close controlling tty in cygheap.
* tty.cc: Change some BOOLs to bools.

41 files changed:
winsup/cygwin/ChangeLog
winsup/cygwin/cygheap.h
winsup/cygwin/dcrt0.cc
winsup/cygwin/debug.cc
winsup/cygwin/debug.h
winsup/cygwin/devices.cc
winsup/cygwin/devices.in
winsup/cygwin/dtable.cc
winsup/cygwin/dtable.h
winsup/cygwin/fhandler.h
winsup/cygwin/fhandler_console.cc
winsup/cygwin/fhandler_fifo.cc
winsup/cygwin/fhandler_mem.cc
winsup/cygwin/fhandler_random.cc
winsup/cygwin/fhandler_serial.cc
winsup/cygwin/fhandler_socket.cc
winsup/cygwin/fhandler_tape.cc
winsup/cygwin/fhandler_termios.cc
winsup/cygwin/fhandler_tty.cc
winsup/cygwin/fork.cc
winsup/cygwin/grp.cc
winsup/cygwin/localtime.cc
winsup/cygwin/mmap.cc
winsup/cygwin/ntea.cc
winsup/cygwin/passwd.cc
winsup/cygwin/path.cc
winsup/cygwin/path.h
winsup/cygwin/pinfo.cc
winsup/cygwin/pinfo.h
winsup/cygwin/sec_acl.cc
winsup/cygwin/sec_helper.cc
winsup/cygwin/security.cc
winsup/cygwin/security.h
winsup/cygwin/select.cc
winsup/cygwin/sigproc.cc
winsup/cygwin/sigproc.h
winsup/cygwin/spawn.cc
winsup/cygwin/strace.cc
winsup/cygwin/syscalls.cc
winsup/cygwin/tty.cc
winsup/cygwin/tty.h

index 3aa4c1b..062c635 100644 (file)
@@ -1,3 +1,39 @@
+2003-12-07  Christopher Faylor  <cgf@redhat.com>
+
+       Change use of BOOL, TRUE, FALSE to bool, true, false, as appropriate,
+       throughout.
+
+2003-12-07  Pierre Humblet  <pierre.humblet@ieee.org>
+
+       * tty.cc (tty::common_init): Remove call to SetKernelObjectSecurity and
+       edit some comments.
+
+2003-12-07  Christopher Faylor  <cgf@redhat.com>
+
+       * cygheap.h (init_cygheap::ctty): Add new element.
+       * devices.in (device::parse): Remove special handling for /dev/tty.
+       * devices.cc: Regenerate.
+       * dtable.cc (build_fh_pc): Don't reset /dev/tty device.  Let the device
+       opener do that.
+       * fhandler_termios.cc (tty_min::set_ctty): Redefine to _pinfo class.
+       * fhandler_tty.cc (fhandler_tty_common::set_close_on_exec): Avoid
+       setting noninherit flag for ctty.
+       * tty.h: Move BOOLs to bools.
+       (tty_min::set_ctty): Redeclare to _pinfo class.
+       * pinfo.cc (_pinfo::set_ctty): Define new function based on
+       tty_min::set_ctty.  Change first argument from tty number to tty_min
+       class.
+       * pinfo.h (_pinfo::set_ctty): Declare.
+       * fhandler_console.cc (fhandler_console::get_tty_stuff): Reflect move
+       of set_ctty to _pinfo class.
+       * fhandler_tty.cc (fhandler_tty_slave::open): Treat FH_TTY specially.
+       Use saved cygheap value if it exists.  Otherwise convert to real device
+       and save on first time open.
+       (fhandler_tty_common::dup): Potentially set controlling tty if duping a
+       slave tty.
+       * syscalls.cc (setsid): Close controlling tty in cygheap.
+       * tty.cc: Change some BOOLs to bools.
+
 2003-12-07  Pierre Humblet <pierre.humblet@ieee.org>
 
        * syscalls.cc (locked_append): New.
index 9ce51cc..d326f59 100644 (file)
@@ -125,7 +125,7 @@ public:
      since this class is always allocated statically.  That means that everything
      is zero anyway so there is no need to initialize it to zero.  Since the
      token initialization is always handled during process startup as well,
-     I've removed the constructor entirely.  Please reinstate this f this
+     I've removed the constructor entirely.  Please reinstate this if this
      situation ever changes.
   cygheap_user () : pname (NULL), plogsrv (NULL), pdomain (NULL),
                    homedrive (NULL), homepath (NULL),
@@ -259,6 +259,8 @@ struct init_cygheap
   cygheap_debug debug;
 #endif
   struct sigaction *sigs;
+
+  fhandler_tty_slave ctty;     /* Current tty */
 };
 
 #define CYGHEAPSIZE (sizeof (init_cygheap) + (20000 * sizeof (fhandler_union)) + (5 * 65536))
index 575a2ba..0f6a133 100644 (file)
@@ -51,7 +51,7 @@ per_thread NO_COPY *threadstuff[] = {&waitq_storage,
 
 bool display_title;
 bool strip_title_path;
-bool allow_glob = TRUE;
+bool allow_glob = true;
 codepage_type current_codepage = ansi_cp;
 
 int cygwin_finished_initializing;
@@ -103,7 +103,7 @@ extern "C"
    /* impure_ptr */ &reent_data,
   };
   bool ignore_case_with_glob;
-  int __declspec (dllexport) _check_for_executable = TRUE;
+  int __declspec (dllexport) _check_for_executable = true;
 #ifdef DEBUGGING
   int pinger;
 #endif
@@ -153,7 +153,7 @@ do_global_ctors (void (**in_pfunc)(), int force)
  * A \@file is replaced with @file so that echo \@foo would print
  * @foo and not the contents of foo.
  */
-static int __stdcall
+static bool __stdcall
 insert_file (char *name, char *&cmd)
 {
   HANDLE f;
@@ -170,7 +170,7 @@ insert_file (char *name, char *&cmd)
   if (f == INVALID_HANDLE_VALUE)
     {
       debug_printf ("couldn't open file '%s', %E", name);
-      return FALSE;
+      return false;
     }
 
   /* This only supports files up to about 4 billion bytes in
@@ -180,7 +180,7 @@ insert_file (char *name, char *&cmd)
   if (size == 0xFFFFFFFF)
     {
       debug_printf ("couldn't get file size for '%s', %E", name);
-      return FALSE;
+      return false;
     }
 
   int new_size = strlen (cmd) + size + 2;
@@ -188,7 +188,7 @@ insert_file (char *name, char *&cmd)
   if (!tmp)
     {
       debug_printf ("malloc failed, %E");
-      return FALSE;
+      return false;
     }
 
   /* realloc passed as it should */
@@ -199,13 +199,13 @@ insert_file (char *name, char *&cmd)
   if (!rf_result || (rf_read != size))
     {
       debug_printf ("ReadFile failed, %E");
-      return FALSE;
+      return false;
     }
 
   tmp[size++] = ' ';
   strcpy (tmp + size, cmd);
   cmd = tmp;
-  return TRUE;
+  return true;
 }
 
 static inline int
@@ -769,7 +769,7 @@ dll_crt0_1 ()
     }
 
   /* Disable case-insensitive globbing */
-  ignore_case_with_glob = FALSE;
+  ignore_case_with_glob = false;
 
   /* Flush signals and ensure that signal thread is up and running. Can't
      do this for noncygwin case since the signal thread is blocked due to
@@ -943,7 +943,7 @@ cygwin_dll_init ()
 extern "C" void
 __main (void)
 {
-  do_global_ctors (user_data->ctors, FALSE);
+  do_global_ctors (user_data->ctors, false);
 }
 
 exit_states NO_COPY exit_state;
index fc51560..4f1d6df 100644 (file)
@@ -53,7 +53,7 @@ class lock_debug
 
 muto NO_COPY *lock_debug::locker = NULL;
 
-static bool __stdcall mark_closed (const char *, int, HANDLE, const char *, BOOL);
+static bool __stdcall mark_closed (const char *, int, HANDLE, const char *, bool);
 
 void
 debug_init ()
@@ -167,7 +167,7 @@ debug_fixup_after_fork_exec ()
 }
 
 static bool __stdcall
-mark_closed (const char *func, int ln, HANDLE h, const char *name, BOOL force)
+mark_closed (const char *func, int ln, HANDLE h, const char *name, bool force)
 {
   handle_list *hl;
   lock_debug here;
@@ -179,7 +179,7 @@ mark_closed (const char *func, int ln, HANDLE h, const char *name, BOOL force)
       system_printf ("attempt to close protected handle %s:%d(%s<%p>) winpid %d",
                     hl->func, hl->ln, hl->name, hl->h, hl->pid);
       system_printf (" by %s:%d(%s<%p>)", func, ln, name, h);
-      return FALSE;
+      return false;
     }
 
   handle_list *hln;
@@ -193,19 +193,19 @@ mark_closed (const char *func, int ln, HANDLE h, const char *name, BOOL force)
   if (hl)
     delete_handle (hl);
 
-  return TRUE;
+  return true;
 }
 
 /* Close a known handle.  Complain if !force and closing a known handle or
    if the name of the handle being closed does not match the registered name. */
-BOOL __stdcall
-close_handle (const char *func, int ln, HANDLE h, const char *name, BOOL force)
+bool __stdcall
+close_handle (const char *func, int ln, HANDLE h, const char *name, bool force)
 {
-  BOOL ret;
+  bool ret;
   lock_debug here;
 
   if (!mark_closed (func, ln, h, name, force))
-    return FALSE;
+    return false;
 
   ret = CloseHandle (h);
 
index 91f13d1..8941bae 100644 (file)
@@ -13,7 +13,7 @@ details. */
 #include "dlmalloc.h"
 #define MALLOC_CHECK ({\
   debug_printf ("checking malloc pool");\
-  (void)mallinfo ();\
+  (void) mallinfo ();\
 })
 #endif
 
@@ -63,7 +63,7 @@ details. */
 void debug_init ();
 void __stdcall add_handle (const char *, int, HANDLE, const char *, bool = false)
   __attribute__ ((regparm (3)));
-BOOL __stdcall close_handle (const char *, int, HANDLE, const char *, BOOL)
+bool __stdcall close_handle (const char *, int, HANDLE, const char *, bool)
   __attribute__ ((regparm (3)));
 void __stdcall cygbench (const char *s) __attribute__ ((regparm (1)));
 extern "C" void console_printf (const char *fmt,...);
index e2819c1..b0193d0 100644 (file)
@@ -14822,8 +14822,6 @@ device::parse (const char *s)
 
   if (!dev)
     *this = *fs_dev;
-  else if (dev->devn == FH_TTY)
-    tty_to_real_device ();
   else
     *this = *dev;
 }
index 95ac5f3..b55418f 100644 (file)
@@ -86,8 +86,6 @@ device::parse (const char *s)
 
   if (!dev)
     *this = *fs_dev;
-  else if (dev->devn == FH_TTY)
-    tty_to_real_device ();
   else
     *this = *dev;
 }
index 27c543f..e3268ed 100644 (file)
@@ -408,17 +408,11 @@ build_fh_pc (path_conv& pc)
            break;
          case FH_TTY:
            {
-             device newdev = pc.dev;
-             newdev.tty_to_real_device ();
-             switch (newdev)
-               {
-               case FH_CONSOLE:
-                 fh = cnew (fhandler_console) ();
-                 break;
-               case FH_TTYS:
-                 fh = cnew (fhandler_tty_slave) ();
-                 break;
-               }
+             if (myself->ctty == TTY_CONSOLE)
+               fh = cnew (fhandler_console) ();
+             else if (myself->ctty >= 0)
+               fh = cnew (fhandler_tty_slave) ();
+             break;
            }
        }
       }
index 4003df0..7267ce6 100644 (file)
@@ -33,7 +33,7 @@ public:
     { if (cnt_need_fixup_before > 0) --cnt_need_fixup_before; }
   void inc_need_fixup_before ()
     { cnt_need_fixup_before++; }
-  BOOL need_fixup_before ()
+  bool need_fixup_before ()
     { return cnt_need_fixup_before > 0; }
 
   int vfork_child_dup ();
index a553f75..d9212fe 100644 (file)
@@ -302,7 +302,7 @@ class fhandler_base
                       int flags, _off64_t off);
   virtual int munmap (HANDLE h, caddr_t addr, size_t len);
   virtual int msync (HANDLE h, caddr_t addr, size_t len, int flags);
-  virtual BOOL fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
+  virtual bool fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
                                      DWORD size, void *address);
 
   void *operator new (size_t, void *p) {return p;}
@@ -333,7 +333,7 @@ class fhandler_base
   virtual HANDLE& get_handle () { return io_handle; }
   virtual HANDLE& get_io_handle () { return io_handle; }
   virtual HANDLE& get_output_handle () { return io_handle; }
-  virtual bool hit_eof () {return FALSE;}
+  virtual bool hit_eof () {return false;}
   virtual select_record *select_read (select_record *s);
   virtual select_record *select_write (select_record *s);
   virtual select_record *select_except (select_record *s);
@@ -584,10 +584,10 @@ class fhandler_dev_tape: public fhandler_dev_raw
  private:
   int tape_write_marks (int marktype, DWORD len);
   int tape_get_pos (unsigned long *ret);
-  int tape_set_pos (int mode, long count, BOOLEAN sfm_func = FALSE);
+  int tape_set_pos (int mode, long count, bool sfm_func = false);
   int tape_erase (int mode);
   int tape_prepare (int action);
-  BOOLEAN tape_get_feature (DWORD parm);
+  bool tape_get_feature (DWORD parm);
   int tape_get_blocksize (long *min, long *def, long *max, long *cur);
   int tape_set_blocksize (long count);
   int tape_status (struct mtget *get);
@@ -610,7 +610,7 @@ class fhandler_disk_file: public fhandler_base
   HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, _off64_t off);
   int munmap (HANDLE h, caddr_t addr, size_t len);
   int msync (HANDLE h, caddr_t addr, size_t len, int flags);
-  BOOL fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
+  bool fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
                              DWORD size, void *address);
   DIR *opendir ();
   struct dirent *readdir (DIR *);
@@ -709,7 +709,7 @@ class fhandler_termios: public fhandler_base
   HANDLE& get_output_handle () { return output_handle; }
   line_edit_status line_edit (const char *rptr, int nread, termios&);
   void set_output_handle (HANDLE h) { output_handle = h; }
-  void tcinit (tty_min *this_tc, int force = FALSE);
+  void tcinit (tty_min *this_tc, bool force = false);
   virtual int is_tty () { return 1; }
   int tcgetpgrp ();
   int tcsetpgrp (int pid);
@@ -791,8 +791,8 @@ class dev_console
   bool use_mouse;
   bool raw_win32_keyboard_mode;
 
-  BOOL con_to_str (char *d, const char *s, DWORD sz);
-  BOOL str_to_con (char *d, const char *s, DWORD sz);
+  bool con_to_str (char *d, const char *s, DWORD sz);
+  bool str_to_con (char *d, const char *s, DWORD sz);
 
   friend class fhandler_console;
 };
@@ -807,15 +807,15 @@ class fhandler_console: public fhandler_termios
   void set_default_attr ();
   WORD get_win32_attr ();
 
-  BOOL fillin_info ();
+  bool fillin_info ();
   void clear_screen (int, int, int, int);
   void scroll_screen (int, int, int, int, int, int);
-  void cursor_set (BOOL, int, int);
+  void cursor_set (bool, int, int);
   void cursor_get (int *, int *);
   void cursor_rel (int, int);
   const unsigned char *write_normal (unsigned const char*, unsigned const char *);
   void char_command (char);
-  BOOL set_raw_win32_keyboard_mode (BOOL);
+  bool set_raw_win32_keyboard_mode (bool);
   int output_tcsetattr (int a, const struct termios *t);
 
 /* Input calls */
@@ -997,7 +997,7 @@ class fhandler_dev_random: public fhandler_base
   HCRYPTPROV crypt_prov;
   long pseudo;
 
-  BOOL crypt_gen_random (void *ptr, size_t len);
+  bool crypt_gen_random (void *ptr, size_t len);
   int pseudo_write (const void *ptr, size_t len);
   int pseudo_read (void *ptr, size_t len);
 
@@ -1034,7 +1034,7 @@ class fhandler_dev_mem: public fhandler_base
   HANDLE mmap (caddr_t *addr, size_t len, DWORD access, int flags, _off64_t off);
   int munmap (HANDLE h, caddr_t addr, size_t len);
   int msync (HANDLE h, caddr_t addr, size_t len, int flags);
-  BOOL fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
+  bool fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
                              DWORD size, void *address);
 
   void dump ();
index 7386d9c..e5b6120 100644 (file)
@@ -32,7 +32,7 @@ details. */
 
 #define CONVERT_LIMIT 16384
 
-static BOOL
+static bool
 cp_convert (UINT destcp, char *dest, UINT srccp, const char *src, DWORD size)
 {
   if (!size)
@@ -46,12 +46,12 @@ cp_convert (UINT destcp, char *dest, UINT srccp, const char *src, DWORD size)
     {
       WCHAR wbuffer[CONVERT_LIMIT]; /* same size as the maximum input, s.b. */
       if (!MultiByteToWideChar (srccp, 0, src, size, wbuffer, sizeof (wbuffer)))
-       return FALSE;
+       return false;
       if (!WideCharToMultiByte (destcp, 0, wbuffer, size, dest, size,
                                NULL, NULL))
-       return FALSE;
+       return false;
     }
-  return TRUE;
+  return true;
 }
 
 /*
@@ -94,7 +94,7 @@ fhandler_console::get_tty_stuff (int flags = 0)
     {
       shared_console_info->tty_min_state.setntty (TTY_CONSOLE);
       shared_console_info->tty_min_state.setsid (myself->sid);
-      shared_console_info->tty_min_state.set_ctty (TTY_CONSOLE, flags);
+      myself->set_ctty (&shared_console_info->tty_min_state, flags);
 
       dev_state->scroll_region.Bottom = -1;
       dev_state->dwLastCursorPosition.X = -1;
@@ -169,28 +169,28 @@ set_console_state_for_spawn ()
 /* The results of GetConsoleCP() and GetConsoleOutputCP() cannot be
    cached, because a program or the user can change these values at
    any time. */
-inline BOOL
+inline bool
 dev_console::con_to_str (char *d, const char *s, DWORD sz)
 {
   return cp_convert (get_cp (), d, GetConsoleCP (), s, sz);
 }
 
-inline BOOL
+inline bool
 dev_console::str_to_con (char *d, const char *s, DWORD sz)
 {
   if (alternate_charset_active)
     {
       /* no translation when alternate charset is active */
       memcpy(d, s, sz);
-      return TRUE;
+      return true;
     }
   return cp_convert (GetConsoleOutputCP (), d, get_cp (), s, sz);
 }
 
-BOOL
-fhandler_console::set_raw_win32_keyboard_mode (BOOL new_mode)
+bool
+fhandler_console::set_raw_win32_keyboard_mode (bool new_mode)
 {
-  BOOL old_mode = dev_state->raw_win32_keyboard_mode;
+  bool old_mode = dev_state->raw_win32_keyboard_mode;
   dev_state->raw_win32_keyboard_mode = new_mode;
   syscall_printf ("raw keyboard mode %sabled", dev_state->raw_win32_keyboard_mode ? "en" : "dis");
   return old_mode;
@@ -544,10 +544,10 @@ fhandler_console::set_input_state ()
     input_tcsetattr (0, &tc->ti);
 }
 
-BOOL
+bool
 fhandler_console::fillin_info (void)
 {
-  BOOL ret;
+  bool ret;
   CONSOLE_SCREEN_BUFFER_INFO linfo;
 
   if ((ret = GetConsoleScreenBufferInfo (get_output_handle (), &linfo)))
@@ -910,7 +910,7 @@ fhandler_console::fhandler_console () :
 void
 fhandler_console::set_default_attr ()
 {
-  dev_state->blink = dev_state->underline = dev_state->reverse = FALSE;
+  dev_state->blink = dev_state->underline = dev_state->reverse = false;
   dev_state->intensity = INTENSITY_NORMAL;
   dev_state->fg = dev_state->default_color & FOREGROUND_ATTR_MASK;
   dev_state->bg = dev_state->default_color & BACKGROUND_ATTR_MASK;
@@ -993,7 +993,7 @@ fhandler_console::clear_screen (int x1, int y1, int x2, int y2)
 }
 
 void
-fhandler_console::cursor_set (BOOL rel_to_top, int x, int y)
+fhandler_console::cursor_set (bool rel_to_top, int x, int y)
 {
   COORD pos;
 
@@ -1021,7 +1021,7 @@ fhandler_console::cursor_rel (int x, int y)
   fillin_info ();
   x += dev_state->info.dwCursorPosition.X;
   y += dev_state->info.dwCursorPosition.Y;
-  cursor_set (FALSE, x, y);
+  cursor_set (false, x, y);
 }
 
 void
@@ -1106,10 +1106,10 @@ fhandler_console::char_command (char c)
               dev_state->underline = 1;
               break;
             case 5:    /* blink mode */
-              dev_state->blink = TRUE;
+              dev_state->blink = true;
               break;
             case 7:    /* reverse */
-              dev_state->reverse = TRUE;
+              dev_state->reverse = true;
               break;
             case 8:    /* invisible */
               dev_state->intensity = INTENSITY_INVISIBLE;
@@ -1118,16 +1118,16 @@ fhandler_console::char_command (char c)
               dev_state->intensity = INTENSITY_DIM;
               break;
              case 10:   /* end alternate charset */
-               dev_state->alternate_charset_active = FALSE;
+               dev_state->alternate_charset_active = false;
               break;
              case 11:   /* start alternate charset */
-               dev_state->alternate_charset_active = TRUE;
+               dev_state->alternate_charset_active = true;
               break;
             case 24:
-              dev_state->underline = FALSE;
+              dev_state->underline = false;
               break;
             case 27:
-              dev_state->reverse = FALSE;
+              dev_state->reverse = false;
               break;
             case 30:           /* BLACK foreground */
               dev_state->fg = 0;
@@ -1194,7 +1194,7 @@ fhandler_console::char_command (char c)
          switch (dev_state->args_[0])
            {
            case 4:    /* Insert mode */
-             dev_state->insert_mode = (c == 'h') ? TRUE : FALSE;
+             dev_state->insert_mode = (c == 'h') ? true : false;
              syscall_printf ("insert mode %sabled", dev_state->insert_mode ? "en" : "dis");
              break;
            }
@@ -1243,12 +1243,12 @@ fhandler_console::char_command (char c)
          break;
 
        case 1000: /* Mouse support */
-         dev_state->use_mouse = (c == 'h') ? TRUE : FALSE;
+         dev_state->use_mouse = (c == 'h') ? true : false;
          syscall_printf ("mouse support %sabled", dev_state->use_mouse ? "en" : "dis");
          break;
 
        case 2000: /* Raw keyboard mode */
-         set_raw_win32_keyboard_mode ((c == 'h') ? TRUE : FALSE);
+         set_raw_win32_keyboard_mode ((c == 'h') ? true : false);
          break;
 
        default: /* Ignore */
@@ -1269,7 +1269,7 @@ fhandler_console::char_command (char c)
          break;
        case 2:                 /* Clear screen */
          clear_screen (0, 0, -1, -1);
-         cursor_set (TRUE, 0,0);
+         cursor_set (true, 0,0);
          break;
        default:
          goto bad_escape;
@@ -1309,27 +1309,27 @@ fhandler_console::char_command (char c)
       break;
     case 'H':
     case 'f':
-      cursor_set (TRUE, (dev_state->args_[1] ? dev_state->args_[1] : 1) - 1,
+      cursor_set (true, (dev_state->args_[1] ? dev_state->args_[1] : 1) - 1,
                        (dev_state->args_[0] ? dev_state->args_[0] : 1) - 1);
       break;
     case 'G':   /* hpa - position cursor at column n - 1 */
       cursor_get (&x, &y);
-      cursor_set (FALSE, (dev_state->args_[0] ? dev_state->args_[0] - 1 : 0), y);
+      cursor_set (false, (dev_state->args_[0] ? dev_state->args_[0] - 1 : 0), y);
       break;
     case 'd':   /* vpa - position cursor at line n */
       cursor_get (&x, &y);
-      cursor_set (TRUE, x, (dev_state->args_[0] ? dev_state->args_[0] - 1 : 0));
+      cursor_set (true, x, (dev_state->args_[0] ? dev_state->args_[0] - 1 : 0));
       break;
     case 's':   /* Save cursor position */
       cursor_get (&dev_state->savex, &dev_state->savey);
       dev_state->savey -= dev_state->info.winTop;
       break;
     case 'u':   /* Restore cursor position */
-      cursor_set (TRUE, dev_state->savex, dev_state->savey);
+      cursor_set (true, dev_state->savex, dev_state->savey);
       break;
     case 'I':  /* TAB */
       cursor_get (&x, &y);
-      cursor_set (FALSE, 8 * (x / 8 + 1), y);
+      cursor_set (false, 8 * (x / 8 + 1), y);
       break;
     case 'L':                          /* AL - insert blank lines */
       dev_state->args_[0] = dev_state->args_[0] ? dev_state->args_[0] : 1;
@@ -1368,7 +1368,7 @@ fhandler_console::char_command (char c)
       break;
     case 'Z':                          /* Back tab */
       cursor_get (&x, &y);
-      cursor_set (FALSE, ((8 * (x / 8 + 1)) - 8), y);
+      cursor_set (false, ((8 * (x / 8 + 1)) - 8), y);
       break;
     case 'b':                          /* Repeat char #1 #2 times */
       if (dev_state->insert_mode)
@@ -1400,7 +1400,7 @@ fhandler_console::char_command (char c)
     case 'r':                          /* Set Scroll region */
       dev_state->scroll_region.Top = dev_state->args_[0] ? dev_state->args_[0] - 1 : 0;
       dev_state->scroll_region.Bottom = dev_state->args_[1] ? dev_state->args_[1] - 1 : -1;
-      cursor_set (TRUE, 0, 0);
+      cursor_set (true, 0, 0);
       break;
     case 'g':                          /* TAB set/clear */
       break;
@@ -1484,7 +1484,7 @@ fhandler_console::write_normal (const unsigned char *src,
                  y--;
                }
            }
-         cursor_set (FALSE, ((tc->ti.c_oflag & ONLCR) ? 0 : x), y + 1);
+         cursor_set (false, ((tc->ti.c_oflag & ONLCR) ? 0 : x), y + 1);
          break;
        case BAK:
          cursor_rel (-1, 0);
@@ -1494,14 +1494,14 @@ fhandler_console::write_normal (const unsigned char *src,
          break;
        case CR:
          cursor_get (&x, &y);
-         cursor_set (FALSE, 0, y);
+         cursor_set (false, 0, y);
          break;
        case ERR:
          WriteFile (get_output_handle (), src, 1, &done, 0);
          break;
        case TAB:
          cursor_get (&x, &y);
-         cursor_set (FALSE, 8 * (x / 8 + 1), y);
+         cursor_set (false, 8 * (x / 8 + 1), y);
          break;
        }
       src ++;
@@ -1533,7 +1533,7 @@ fhandler_console::write (const void *vsrc, size_t len)
          if (*src == '[')
            {
              dev_state->state_ = gotsquare;
-             dev_state->saw_question_mark = FALSE;
+             dev_state->saw_question_mark = false;
              for (dev_state->nargs_ = 0; dev_state->nargs_ < MAXARGS; dev_state->nargs_++)
                dev_state->args_[dev_state->nargs_] = 0;
              dev_state->nargs_ = 0;
@@ -1554,12 +1554,12 @@ fhandler_console::write (const void *vsrc, size_t len)
            {
              set_default_attr ();
              clear_screen (0, 0, -1, -1);
-             cursor_set (TRUE, 0, 0);
+             cursor_set (true, 0, 0);
              dev_state->state_ = normal;
            }
          else if (*src == '8')         /* Restore cursor position */
            {
-             cursor_set (TRUE, dev_state->savex, dev_state->savey);
+             cursor_set (true, dev_state->savex, dev_state->savey);
              dev_state->state_ = normal;
            }
          else if (*src == '7')         /* Save cursor position */
@@ -1641,7 +1641,7 @@ fhandler_console::write (const void *vsrc, size_t len)
          else if (*src != '@' && !isalpha (*src) && !isdigit (*src))
            {
              if (*src == '?')
-               dev_state->saw_question_mark = TRUE;
+               dev_state->saw_question_mark = true;
              /* ignore any extra chars between [ and first arg or command */
              src++;
            }
index b717e96..d886899 100644 (file)
@@ -1,6 +1,6 @@
 /* fhandler_fifo.cc.  See fhandler.h for a description of the fhandler classes.
 
-   Copyright 2002 Red Hat, Inc.
+   Copyright 2002, 2003 Red Hat, Inc.
 
    This file is part of Cygwin.
 
index 70a3637..b9807d1 100644 (file)
@@ -366,7 +366,7 @@ fhandler_dev_mem::msync (HANDLE h, caddr_t addr, size_t len, int flags)
   return 0;
 }
 
-BOOL
+bool
 fhandler_dev_mem::fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
                                         DWORD size, void *address)
 {
@@ -398,7 +398,7 @@ fhandler_dev_mem::fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
     {
       __seterrno_from_win_error (RtlNtStatusToDosError (ret));
       syscall_printf ("-1 = fixup_mmap_after_fork(): NtMapViewOfSection failed with %E");
-      return FALSE;
+      return false;
     }
   return base == address;
 }
index 5117ba9..a90b703 100644 (file)
@@ -37,7 +37,7 @@ fhandler_dev_random::open (int flags, mode_t)
   return 1;
 }
 
-BOOL
+bool
 fhandler_dev_random::crypt_gen_random (void *ptr, size_t len)
 {
   if (!crypt_prov
@@ -48,14 +48,14 @@ fhandler_dev_random::crypt_gen_random (void *ptr, size_t len)
                               | CRYPT_NEWKEYSET))
     {
       debug_printf ("%E = CryptAquireContext()");
-      return FALSE;
+      return false;
     }
   if (!CryptGenRandom (crypt_prov, len, (BYTE *)ptr))
     {
       debug_printf ("%E = CryptGenRandom()");
-      return FALSE;
+      return false;
     }
-  return TRUE;
+  return true;
 }
 
 int
index 45c3cc1..af39412 100644 (file)
@@ -526,7 +526,7 @@ fhandler_serial::tcsetattr (int action, const struct termios *t)
     TCSAFLUSH: flush output and discard input, then change attributes.
   */
 
-  BOOL dropDTR = FALSE;
+  bool dropDTR = false;
   COMMTIMEOUTS to;
   DCB ostate, state;
   unsigned int ovtime = vtime_, ovmin = vmin_;
@@ -557,7 +557,7 @@ fhandler_serial::tcsetattr (int action, const struct termios *t)
     case B0:
       /* Drop DTR - but leave DCB-resident bitrate as-is since
         0 is an invalid bitrate in Win32 */
-      dropDTR = TRUE;
+      dropDTR = true;
       break;
     case B110:
       state.BaudRate = CBR_110;
@@ -740,7 +740,7 @@ fhandler_serial::tcsetattr (int action, const struct termios *t)
   set_r_binary ((t->c_iflag & IGNCR) ? 0 : 1);
   set_w_binary ((t->c_oflag & ONLCR) ? 0 : 1);
 
-  if (dropDTR == TRUE)
+  if (dropDTR)
     {
       EscapeCommFunction (get_handle (), CLRDTR);
       tmpDtr = 0;
@@ -951,7 +951,7 @@ fhandler_serial::tcgetattr (struct termios *t)
   /* -------------- Parity errors ------------------ */
 
   /* fParity combines the function of INPCK and NOT IGNPAR */
-  if (state.fParity == TRUE)
+  if (state.fParity)
     t->c_iflag |= INPCK;
   else
     t->c_iflag |= IGNPAR;      /* not necessarily! */
@@ -976,8 +976,7 @@ fhandler_serial::tcgetattr (struct termios *t)
      this is what we do. */
 
   /* Input flow-control */
-  if ((state.fRtsControl == RTS_CONTROL_HANDSHAKE) &&
-      (state.fOutxCtsFlow == TRUE))
+  if ((state.fRtsControl == RTS_CONTROL_HANDSHAKE) && state.fOutxCtsFlow)
     t->c_cflag |= CRTSCTS;
   if (state.fRtsControl == RTS_CONTROL_HANDSHAKE)
     t->c_cflag |= CRTSXOFF;
@@ -988,7 +987,7 @@ fhandler_serial::tcgetattr (struct termios *t)
   /* FIXME: If tcsetattr() hasn't been called previously, this may
      give a false CLOCAL. */
 
-  if (state.fDsrSensitivity == FALSE)
+  if (!state.fDsrSensitivity)
     t->c_cflag |= CLOCAL;
 
   /* FIXME: need to handle IGNCR */
index 626818a..8d8f9cb 100644 (file)
@@ -487,8 +487,8 @@ int
 fhandler_socket::connect (const struct sockaddr *name, int namelen)
 {
   int res = -1;
-  BOOL secret_check_failed = FALSE;
-  BOOL in_progress = FALSE;
+  bool secret_check_failed = false;
+  bool in_progress = false;
   sockaddr_in sin;
   int secret [4];
   DWORD err;
@@ -506,7 +506,7 @@ fhandler_socket::connect (const struct sockaddr *name, int namelen)
        {
          err = WSAGetLastError ();
          if (err == WSAEWOULDBLOCK || err == WSAEALREADY)
-           in_progress = TRUE;
+           in_progress = true;
 
          if (err == WSAEWOULDBLOCK)
            WSASetLastError (WSAEINPROGRESS);
@@ -521,7 +521,7 @@ fhandler_socket::connect (const struct sockaddr *name, int namelen)
        {
          if (!create_secret_event (secret))
            {
-             secret_check_failed = TRUE;
+             secret_check_failed = true;
            }
          else if (in_progress)
            signal_secret_event ();
@@ -532,7 +532,7 @@ fhandler_socket::connect (const struct sockaddr *name, int namelen)
          if (!check_peer_secret_event (&sin, secret))
            {
              debug_printf ("accept from unauthorized server");
-             secret_check_failed = TRUE;
+             secret_check_failed = true;
            }
        }
 
@@ -570,8 +570,8 @@ int
 fhandler_socket::accept (struct sockaddr *peer, int *len)
 {
   int res = -1;
-  BOOL secret_check_failed = FALSE;
-  BOOL in_progress = FALSE;
+  bool secret_check_failed = false;
+  bool in_progress = false;
 
   /* Allows NULL peer and len parameters. */
   struct sockaddr_in peer_dummy;
@@ -594,14 +594,14 @@ fhandler_socket::accept (struct sockaddr *peer, int *len)
   res = ::accept (get_socket (), peer, len);
 
   if ((SOCKET) res == INVALID_SOCKET && WSAGetLastError () == WSAEWOULDBLOCK)
-    in_progress = TRUE;
+    in_progress = true;
 
   if (get_addr_family () == AF_LOCAL && get_socket_type () == SOCK_STREAM)
     {
       if ((SOCKET) res != INVALID_SOCKET || in_progress)
        {
          if (!create_secret_event ())
-           secret_check_failed = TRUE;
+           secret_check_failed = true;
          else if (in_progress)
            signal_secret_event ();
        }
@@ -612,7 +612,7 @@ fhandler_socket::accept (struct sockaddr *peer, int *len)
          if (!check_peer_secret_event ((struct sockaddr_in*) peer))
            {
              debug_printf ("connect from unauthorized client");
-             secret_check_failed = TRUE;
+             secret_check_failed = true;
            }
        }
 
index e3efcd1..8711246 100644 (file)
@@ -273,14 +273,14 @@ fhandler_dev_tape::ioctl (unsigned int cmd, void *buf)
          case MTRETEN:
            if (! tape_get_feature (TAPE_DRIVE_END_OF_DATA))
              ret = ERROR_INVALID_PARAMETER;
-           else if (! (ret = tape_set_pos (TAPE_REWIND, 0, FALSE)))
+           else if (! (ret = tape_set_pos (TAPE_REWIND, 0, false)))
              ret = tape_prepare (TAPE_TENSION);
            break;
          case MTBSFM:
-           ret = tape_set_pos (TAPE_SPACE_FILEMARKS, -op->mt_count, TRUE);
+           ret = tape_set_pos (TAPE_SPACE_FILEMARKS, -op->mt_count, true);
            break;
          case MTFSFM:
-           ret = tape_set_pos (TAPE_SPACE_FILEMARKS, op->mt_count, TRUE);
+           ret = tape_set_pos (TAPE_SPACE_FILEMARKS, op->mt_count, true);
            break;
          case MTEOM:
            if (tape_get_feature (TAPE_DRIVE_END_OF_DATA))
@@ -497,7 +497,7 @@ static int _tape_set_pos (HANDLE hTape, int mode, long count)
 }
 
 int
-fhandler_dev_tape::tape_set_pos (int mode, long count, BOOLEAN sfm_func)
+fhandler_dev_tape::tape_set_pos (int mode, long count, bool sfm_func)
 {
   unsigned long pos, tgtpos;
 
@@ -603,7 +603,7 @@ fhandler_dev_tape::tape_erase (int mode)
        break;
     }
 
-  return tape_error (EraseTape (get_handle (), mode, FALSE), "tape_erase");
+  return tape_error (EraseTape (get_handle (), mode, false), "tape_erase");
 }
 
 int
@@ -617,7 +617,7 @@ fhandler_dev_tape::tape_prepare (int action)
   return tape_error (lasterr, "tape_prepare");
 }
 
-BOOLEAN
+bool
 fhandler_dev_tape::tape_get_feature (DWORD parm)
 {
   DWORD varlen;
@@ -631,7 +631,7 @@ fhandler_dev_tape::tape_get_feature (DWORD parm)
     ;
 
   if (lasterr)
-    return FALSE;
+    return false;
 
   return ((parm & TAPE_DRIVE_HIGH_FEATURES)
          ? ((dp.FeaturesHigh & parm) != 0)
index 1b509e2..edb8354 100644 (file)
@@ -25,7 +25,7 @@ details. */
 /* Common functions shared by tty/console */
 
 void
-fhandler_termios::tcinit (tty_min *this_tc, int force)
+fhandler_termios::tcinit (tty_min *this_tc, bool force)
 {
   /* Initial termios values */
 
@@ -101,32 +101,6 @@ tty_min::kill_pgrp (int sig)
     sig_send (myself, sig);
 }
 
-void
-tty_min::set_ctty (int ttynum, int flags)
-{
-  if ((myself->ctty < 0 || myself->ctty == ttynum) && !(flags & O_NOCTTY))
-    {
-      myself->ctty = ttynum;
-      syscall_printf ("attached tty%d sid %d, pid %d, tty->pgid %d, tty->sid %d",
-                     ttynum, myself->sid, myself->pid, pgid, getsid ());
-
-      pinfo p (getsid ());
-      if (myself->sid == myself->pid &&
-         (p == myself || !proc_exists (p)))
-       {
-         paranoid_printf ("resetting tty%d sid.  Was %d, now %d.  pgid was %d, now %d.",
-                          ttynum, getsid (), myself->sid, getpgid (), myself->pgid);
-         /* We are the session leader */
-         setsid (myself->sid);
-         setpgid (myself->pgid);
-       }
-      else
-       myself->sid = getsid ();
-      if (getpgid () == 0)
-       setpgid (myself->pgid);
-    }
-}
-
 bg_check_types
 fhandler_termios::bg_check (int sig)
 {
index 377a875..a27ee58 100644 (file)
@@ -447,10 +447,20 @@ fhandler_tty_slave::fhandler_tty_slave ()
 int
 fhandler_tty_slave::open (int flags, mode_t)
 {
+  if (get_device () != FH_TTY)
+    /* nothing to do */;
+  else if (!cygheap->ctty.get_io_handle ())
+    pc.dev.tty_to_real_device ();
+  else
+    {
+      *this = cygheap->ctty;
+      termios_printf ("copied tty fhandler from cygheap");
+      return 1;
+    }
+
   tcinit (cygwin_shared->tty[get_unit ()]);
 
   attach_tty (get_unit ());
-  tc->set_ctty (get_unit (), flags);
 
   set_flags ((flags & ~O_TEXT) | O_BINARY);
   /* Create synchronisation events */
@@ -495,7 +505,7 @@ fhandler_tty_slave::open (int flags, mode_t)
   {
     acquire_output_mutex (500);
     inuse = get_ttyp ()->create_inuse (TTY_SLAVE_ALIVE);
-    get_ttyp ()->was_opened = TRUE;
+    get_ttyp ()->was_opened = true;
     release_output_mutex ();
   }
 
@@ -508,7 +518,8 @@ fhandler_tty_slave::open (int flags, mode_t)
       return 0;
     }
 
-  HANDLE from_master_local, to_master_local;
+  HANDLE from_master_local = NULL;
+  HANDLE to_master_local = NULL;
 
 #ifdef USE_SERVER
   if (!wincap.has_security ()
@@ -557,6 +568,7 @@ fhandler_tty_slave::open (int flags, mode_t)
 
   set_io_handle (from_master_local);
   set_output_handle (to_master_local);
+  myself->set_ctty (get_ttyp (), flags, this);
 
   set_open_status ();
   if (fhandler_console::open_fhs++ == 0 && !GetConsoleCP ()
@@ -589,6 +601,8 @@ fhandler_tty_slave::close ()
   if (!--fhandler_console::open_fhs && myself->ctty == -1)
     FreeConsole ();
   termios_printf ("decremented open_fhs %d", fhandler_console::open_fhs);
+  if (!exit_state && get_io_handle () == cygheap->ctty.get_io_handle ())
+    return 1;
   return fhandler_tty_common::close ();
 }
 
@@ -886,7 +900,6 @@ fhandler_tty_common::dup (fhandler_base *child)
   fts->tcinit (get_ttyp ());
 
   attach_tty (get_unit ());
-  tc->set_ctty (get_unit (), openflags);
 
   HANDLE nh;
 
@@ -965,6 +978,10 @@ fhandler_tty_common::dup (fhandler_base *child)
       errind = 9;
       goto err;
     }
+
+  if (get_major () == DEV_TTYS_MAJOR)
+    myself->set_ctty (get_ttyp (), openflags, (fhandler_tty_slave *) this);
+
   return 0;
 
 err:
@@ -1298,18 +1315,24 @@ fhandler_tty_common::set_close_on_exec (int val)
   set_inheritance (get_io_handle (), val);
   set_close_on_exec_flag (val);
 #endif
-  if (output_done_event)
-    set_inheritance (output_done_event, val);
-  if (ioctl_request_event)
-    set_inheritance (ioctl_request_event, val);
-  if (ioctl_done_event)
-    set_inheritance (ioctl_done_event, val);
-  if (inuse)
-    set_inheritance (inuse, val);
-  set_inheritance (output_mutex, val);
-  set_inheritance (input_mutex, val);
-  set_inheritance (input_available_event, val);
-  set_inheritance (output_handle, val);
+  if (get_major () == DEV_TTYS_MAJOR
+      && get_io_handle () == cygheap->ctty.get_io_handle ())
+    set_close_on_exec_flag (val);
+  else
+    {
+      if (output_done_event)
+       set_inheritance (output_done_event, val);
+      if (ioctl_request_event)
+       set_inheritance (ioctl_request_event, val);
+      if (ioctl_done_event)
+       set_inheritance (ioctl_done_event, val);
+      if (inuse)
+       set_inheritance (inuse, val);
+      set_inheritance (output_mutex, val);
+      set_inheritance (input_mutex, val);
+      set_inheritance (input_available_event, val);
+      set_inheritance (output_handle, val);
+    }
 }
 
 void
index 309f3df..e6ab939 100644 (file)
@@ -129,7 +129,7 @@ fork_copy (PROCESS_INFORMATION &pi, const char *what, ...)
    time out, set errno = EAGAIN and hope the app tries again.  */
 static int
 sync_with_child (PROCESS_INFORMATION &pi, HANDLE subproc_ready,
-                BOOL hang_child, const char *s)
+                bool hang_child, const char *s)
 {
   /* We also add the child process handle to the wait. If the child fails
      to initialize (eg. because of a missing dll). Then this
@@ -238,7 +238,7 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls)
      Don't call setuid here! The flags are already set. */
   cygheap->user.reimpersonate ();
 
-  sync_with_parent ("after longjmp.", TRUE);
+  sync_with_parent ("after longjmp", true);
   sigproc_printf ("hParent %p, child 1 first_dll %p, load_dlls %d", hParent,
                  first_dll, load_dlls);
 
@@ -284,14 +284,14 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls)
     {
       cygheap->fdtab.fixup_after_fork (hParent);
       ProtectHandleINH (hParent);
-      sync_with_parent ("performed fork fixup.", FALSE);
+      sync_with_parent ("performed fork fixup", false);
     }
   else
     {
       dlls.load_after_fork (hParent, first_dll);
       cygheap->fdtab.fixup_after_fork (hParent);
       ProtectHandleINH (hParent);
-      sync_with_parent ("loaded dlls", TRUE);
+      sync_with_parent ("loaded dlls", true);
     }
 
   ForceCloseHandle (hParent);
@@ -541,7 +541,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
 #endif
 
   /* Wait for subproc to initialize itself. */
-  if (!sync_with_child (pi, subproc_ready, TRUE, "waiting for longjmp"))
+  if (!sync_with_child (pi, subproc_ready, true, "waiting for longjmp"))
     goto cleanup;
 
   /* CHILD IS STOPPED */
index 6e34a3a..c185b26 100644 (file)
@@ -180,7 +180,7 @@ grp32togrp16 (struct __group16 *gp16, struct __group32 *gp32)
 extern "C" struct __group32 *
 getgrgid32 (__gid32_t gid)
 {
-  return internal_getgrgid (gid, TRUE);
+  return internal_getgrgid (gid, true);
 }
 
 extern "C" struct __group16 *
@@ -194,7 +194,7 @@ getgrgid (__gid16_t gid)
 extern "C" struct __group32 *
 getgrnam32 (const char *name)
 {
-  return internal_getgrnam (name, TRUE);
+  return internal_getgrnam (name, true);
 }
 
 extern "C" struct __group16 *
index 803033d..3a64d68 100644 (file)
@@ -196,14 +196,6 @@ extern int unlink P((const char * filename));
 ** Finally, some convenience items.
 */
 
-#ifndef TRUE
-#define TRUE   1
-#endif /* !defined TRUE */
-
-#ifndef FALSE
-#define FALSE  0
-#endif /* !defined FALSE */
-
 #ifndef TYPE_BIT
 #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
 #endif /* !defined TYPE_BIT */
@@ -344,13 +336,13 @@ struct tzhead {
 **     tzh_leapcnt repetitions of
 **             one (char [4])          coded leap second transition times
 **             one (char [4])          total correction after above
-**     tzh_ttisstdcnt (char)s          indexed by type; if TRUE, transition
-**                                     time is standard time, if FALSE,
+**     tzh_ttisstdcnt (char)s          indexed by type; if true, transition
+**                                     time is standard time, if false,
 **                                     transition time is wall clock time
 **                                     if absent, transition times are
 **                                     assumed to be wall clock time
-**     tzh_ttisgmtcnt (char)s          indexed by type; if TRUE, transition
-**                                     time is UTC, if FALSE,
+**     tzh_ttisgmtcnt (char)s          indexed by type; if true, transition
+**                                     time is UTC, if false,
 **                                     transition time is local time
 **                                     if absent, transition times are
 **                                     assumed to be local time
@@ -504,8 +496,8 @@ struct ttinfo {                             /* time type information */
        long            tt_gmtoff;      /* UTC offset in seconds */
        int             tt_isdst;       /* used to set tm_isdst */
        int             tt_abbrind;     /* abbreviation list index */
-       int             tt_ttisstd;     /* TRUE if transition is std time */
-       int             tt_ttisgmt;     /* TRUE if transition is UTC */
+       int             tt_ttisstd;     /* true if transition is std time */
+       int             tt_ttisgmt;     /* true if transition is UTC */
 };
 
 struct lsinfo {                                /* leap second information */
@@ -745,7 +737,7 @@ tzload(const char *name, struct state *sp)
                        ** Set doaccess if '.' (as in "../") shows up in name.
                        */
                        if (strchr(name, '.') != NULL)
-                               doaccess = TRUE;
+                               doaccess = true;
                        name = fullname;
                }
 #if 0
@@ -848,11 +840,11 @@ tzload(const char *name, struct state *sp)
 
                        ttisp = &sp->ttis[i];
                        if (ttisstdcnt == 0)
-                               ttisp->tt_ttisstd = FALSE;
+                               ttisp->tt_ttisstd = false;
                        else {
                                ttisp->tt_ttisstd = *p++;
-                               if (ttisp->tt_ttisstd != TRUE &&
-                                       ttisp->tt_ttisstd != FALSE)
+                               if (ttisp->tt_ttisstd != true &&
+                                       ttisp->tt_ttisstd != false)
                                                return -1;
                        }
                }
@@ -861,11 +853,11 @@ tzload(const char *name, struct state *sp)
 
                        ttisp = &sp->ttis[i];
                        if (ttisgmtcnt == 0)
-                               ttisp->tt_ttisgmt = FALSE;
+                               ttisp->tt_ttisgmt = false;
                        else {
                                ttisp->tt_ttisgmt = *p++;
-                               if (ttisp->tt_ttisgmt != TRUE &&
-                                       ttisp->tt_ttisgmt != FALSE)
+                               if (ttisp->tt_ttisgmt != true &&
+                                       ttisp->tt_ttisgmt != false)
                                                return -1;
                        }
                }
@@ -1279,7 +1271,7 @@ tzparse(const char *name, struct state *sp, const int lastditch)
                        /*
                        ** Initially we're assumed to be in standard time.
                        */
-                       isdst = FALSE;
+                       isdst = false;
                        theiroffset = theirstdoffset;
                        /*
                        ** Now juggle transition times and types
@@ -1323,10 +1315,10 @@ tzparse(const char *name, struct state *sp, const int lastditch)
                        ** ttisstd and ttisgmt need not be handled.
                        */
                        sp->ttis[0].tt_gmtoff = -stdoffset;
-                       sp->ttis[0].tt_isdst = FALSE;
+                       sp->ttis[0].tt_isdst = false;
                        sp->ttis[0].tt_abbrind = 0;
                        sp->ttis[1].tt_gmtoff = -dstoffset;
-                       sp->ttis[1].tt_isdst = TRUE;
+                       sp->ttis[1].tt_isdst = true;
                        sp->ttis[1].tt_abbrind = stdlen + 1;
                        sp->typecnt = 2;
                }
@@ -1358,7 +1350,7 @@ static void
 gmtload(struct state *sp)
 {
        if (tzload(gmt, sp) != 0)
-               (void) tzparse(gmt, sp, TRUE);
+               (void) tzparse(gmt, sp, true);
 }
 
 #ifndef STD_INSPIRED
@@ -1449,7 +1441,7 @@ tzsetwall P((void))
                    sprintf(cp=strchr(cp, 0), ":%d", tz.StandardDate.wSecond);
            }
            /* printf("TZ deduced as `%s'\n", buf); */
-           if (tzparse(buf, lclptr, FALSE) == 0) {
+           if (tzparse(buf, lclptr, false) == 0) {
                settzname();
                lcl_is_set = 1;
                strlcpy(lcl_TZname, buf, sizeof (lcl_TZname));
@@ -1498,7 +1490,7 @@ tzset P((void))
                lclptr->ttis[0].tt_abbrind = 0;
                (void) strcpy(lclptr->chars, gmt);
        } else if (tzload(name, lclptr) != 0) {
-               if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0)
+               if (name[0] == ':' || tzparse(name, lclptr, false) != 0)
                        (void) gmtload(lclptr);
        }
        settzname();
@@ -1585,7 +1577,7 @@ static void
 gmtsub(const time_t *timep, const long offset, struct tm *tmp)
 {
        if (!gmt_is_set) {
-               gmt_is_set = TRUE;
+               gmt_is_set = true;
 #ifdef ALL_STATE
                gmtptr = (struct state *) malloc(sizeof *gmtptr);
                if (gmtptr != NULL)
@@ -1827,7 +1819,7 @@ time2sub(struct tm *tmp, void (*funcp) P((const time_t*, long, struct tm*)),
        time_t                          t;
        struct tm                       yourtm, mytm;
 
-       *okayp = FALSE;
+       *okayp = false;
        yourtm = *tmp;
        if (do_norm_secs) {
                if (normalize_overflow(&yourtm.tm_min, &yourtm.tm_sec,
@@ -1958,7 +1950,7 @@ label:
                return WRONG;
        t = newt;
        (*funcp)(&t, offset, tmp);
-       *okayp = TRUE;
+       *okayp = true;
        return t;
 }
 
@@ -1973,8 +1965,8 @@ time2(struct tm *tmp, void (*funcp) P((const time_t*, long, struct tm*)),
        ** (in case tm_sec contains a value associated with a leap second).
        ** If that fails, try with normalization of seconds.
        */
-       t = time2sub(tmp, funcp, offset, okayp, FALSE);
-       return *okayp ? t : time2sub(tmp, funcp, offset, okayp, TRUE);
+       t = time2sub(tmp, funcp, offset, okayp, false);
+       return *okayp ? t : time2sub(tmp, funcp, offset, okayp, true);
 }
 
 static time_t
index 035b99f..7042048 100644 (file)
@@ -92,7 +92,7 @@ class mmap_record
 
     DWORD find_unused_pages (DWORD pages);
     _off64_t map_pages (_off64_t off, DWORD len);
-    BOOL unmap_pages (caddr_t addr, DWORD len);
+    bool unmap_pages (caddr_t addr, DWORD len);
     int access (caddr_t address);
 
     fhandler_base *alloc_fh ();
@@ -230,7 +230,7 @@ mmap_record::map_pages (_off64_t off, DWORD len)
   return off * getpagesize ();
 }
 
-BOOL
+bool
 mmap_record::unmap_pages (caddr_t addr, DWORD len)
 {
   DWORD old_prot;
@@ -248,8 +248,8 @@ mmap_record::unmap_pages (caddr_t addr, DWORD len)
      the whole chunk. */
   for (len = MAPSIZE (PAGE_CNT (size_to_map_)); len > 0; )
     if (page_map_[--len])
-      return FALSE;
-  return TRUE;
+      return false;
+  return true;
 }
 
 void
@@ -860,7 +860,7 @@ fhandler_base::msync (HANDLE h, caddr_t addr, size_t len, int flags)
   return -1;
 }
 
-BOOL
+bool
 fhandler_base::fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
                                      DWORD size, void *address)
 {
@@ -969,7 +969,7 @@ fhandler_disk_file::msync (HANDLE h, caddr_t addr, size_t len, int flags)
   return 0;
 }
 
-BOOL
+bool
 fhandler_disk_file::fixup_mmap_after_fork (HANDLE h, DWORD access, DWORD offset,
                                           DWORD size, void *address)
 {
@@ -1021,7 +1021,7 @@ fixup_mmaps_after_fork (HANDLE parent)
              rec->get_offset (), rec->get_size (), rec->get_address ());
 
          fhandler_base *fh = rec->alloc_fh ();
-         BOOL ret = fh->fixup_mmap_after_fork (rec->get_handle (),
+         bool ret = fh->fixup_mmap_after_fork (rec->get_handle (),
                                                rec->get_access (),
                                                rec->get_offset (),
                                                rec->get_size (),
index 4841a4c..a195471 100644 (file)
@@ -243,7 +243,7 @@ NTReadEARaw (HANDLE hFileSource, int *len)
  *     buf     - pointer to buffer with EA value.
  *     len     - length of buf.
  * Return value:
- *     TRUE if success, FALSE otherwice.
+ *     true if success, false otherwice.
  * Note: if len=0 given EA will be deleted.
  */
 
@@ -255,7 +255,7 @@ NTWriteEA (const char *file, const char *attrname, const char *buf, int len)
   DWORD dwBytesWritten;
   LPVOID lpContext;
   DWORD StreamSize, easize;
-  BOOL bSuccess=FALSE;
+  bool bSuccess = false;
   PFILE_FULL_EA_INFORMATION ea;
 
   hFileSource = CreateFile (file, FILE_WRITE_EA,
@@ -305,7 +305,7 @@ NTWriteEA (const char *file, const char *attrname, const char *buf, int len)
                    &lpContext))
     goto cleanup;
 
-  bSuccess = TRUE;
+  bSuccess = true;
   /* free context */
 
 cleanup:
index 0c66d99..7a76e5a 100644 (file)
@@ -144,7 +144,7 @@ internal_getpwnam (const char *name, bool check)
 extern "C" struct passwd *
 getpwuid32 (__uid32_t uid)
 {
-  struct passwd *temppw = internal_getpwuid (uid, TRUE);
+  struct passwd *temppw = internal_getpwuid (uid, true);
   pthread_testcancel ();
   return temppw;
 }
@@ -163,7 +163,7 @@ getpwuid_r32 (__uid32_t uid, struct passwd *pwd, char *buffer, size_t bufsize, s
   if (!pwd || !buffer)
     return ERANGE;
 
-  struct passwd *temppw = internal_getpwuid (uid, TRUE);
+  struct passwd *temppw = internal_getpwuid (uid, true);
   pthread_testcancel ();
   if (!temppw)
     return 0;
@@ -202,7 +202,7 @@ getpwuid_r (__uid16_t uid, struct passwd *pwd, char *buffer, size_t bufsize, str
 extern "C" struct passwd *
 getpwnam (const char *name)
 {
-  struct passwd *temppw = internal_getpwnam (name, TRUE);
+  struct passwd *temppw = internal_getpwnam (name, true);
   pthread_testcancel ();
   return temppw;
 }
@@ -220,7 +220,7 @@ getpwnam_r (const char *nam, struct passwd *pwd, char *buffer, size_t bufsize, s
   if (!pwd || !buffer || !nam)
     return ERANGE;
 
-  struct passwd *temppw = internal_getpwnam (nam, TRUE);
+  struct passwd *temppw = internal_getpwnam (nam, true);
   pthread_testcancel ();
 
   if (!temppw)
index a88ad6f..11350d2 100644 (file)
@@ -102,13 +102,13 @@ struct symlink_info
   _mode_t mode;
   int check (char *path, const suffix_info *suffixes, unsigned opt);
   bool parse_device (const char *);
-  BOOL case_check (char *path);
+  bool case_check (char *path);
 };
 
 int pcheck_case = PCHECK_RELAXED; /* Determines the case check behaviour. */
 
 static char shortcut_header[SHORTCUT_HDR_SIZE];
-static BOOL shortcut_initalized;
+static bool shortcut_initalized;
 
 static void
 create_shortcut_header (void)
@@ -123,7 +123,7 @@ create_shortcut_header (void)
       shortcut_header[19] = 'F';
       shortcut_header[20] = '\f';
       shortcut_header[60] = '\001';
-      shortcut_initalized = TRUE;
+      shortcut_initalized = true;
     }
 }
 
@@ -641,7 +641,7 @@ path_conv::check (const char *src, unsigned opt,
            {
              if (pcheck_case == PCHECK_STRICT)
                {
-                 case_clash = TRUE;
+                 case_clash = true;
                  error = ENOENT;
                  goto out;
                }
@@ -650,7 +650,7 @@ path_conv::check (const char *src, unsigned opt,
                 which shall create files to avoid overriding already existing
                 files with another case. */
              if (!component)
-               case_clash = TRUE;
+               case_clash = true;
            }
          if (!(opt & PC_SYM_IGNORE))
            {
@@ -898,7 +898,7 @@ digits (const char *name)
   return p > name && !*p ? n : -1;
 }
 
-/* Return TRUE if src_path is a valid, internally supported device name.
+/* Return true if src_path is a valid, internally supported device name.
    In that case, win32_path gets the corresponding NT device name and
    dev is appropriately filled with device information. */
 
@@ -2195,7 +2195,7 @@ mount_info::del_item (const char *path, unsigned flags, int reg_p)
   else
     {
       slashify (path, pathtmp, 0);
-      posix_path_p = TRUE;
+      posix_path_p = true;
     }
   nofinalslash (pathtmp, pathtmp);
 
@@ -2378,7 +2378,7 @@ mount (const char *win32_path, const char *posix_path, unsigned flags)
       win32_path = NULL;
     }
   else if (!check_null_empty_str_errno (win32_path))
-    res = mount_table->add_item (win32_path, posix_path, flags, TRUE);
+    res = mount_table->add_item (win32_path, posix_path, flags, true);
 
   syscall_printf ("%d = mount (%s, %s, %p)", res, win32_path, posix_path, flags);
   return res;
@@ -2415,7 +2415,7 @@ cygwin_umount (const char *path, unsigned flags)
     }
   else
     {
-      res = mount_table->del_item (path, flags, TRUE);
+      res = mount_table->del_item (path, flags, true);
     }
 
   syscall_printf ("%d = cygwin_umount (%s, %d)", res,  path, flags);
@@ -2455,7 +2455,7 @@ get_symlink_ea (const char* frompath, char* buf, int buf_size)
 }
 
 /* Save symlink to Extended Attribute */
-BOOL
+bool
 set_symlink_ea (const char* frompath, const char* topath)
 {
   if (!NTWriteEA (frompath, SYMLINK_EA_NAME, topath, strlen (topath) + 1))
@@ -2463,14 +2463,14 @@ set_symlink_ea (const char* frompath, const char* topath)
       debug_printf ("Cannot save symlink in EA");
       return false;
     }
-  return TRUE;
+  return true;
 }
 
 /* Create a symlink from FROMPATH to TOPATH. */
 
 /* If TRUE create symlinks as Windows shortcuts, if false create symlinks
    as normal files with magic number and system bit set. */
-int allow_winsymlinks = TRUE;
+bool allow_winsymlinks = true;
 
 extern "C" int
 symlink (const char *topath, const char *frompath)
@@ -2642,7 +2642,7 @@ done:
   return res;
 }
 
-static BOOL
+static bool
 cmp_shortcut_header (const char *file_header)
 {
   create_shortcut_header ();
@@ -3061,7 +3061,7 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt)
    Dont't call if pcheck_case == PCHECK_RELAXED.
 */
 
-BOOL
+bool
 symlink_info::case_check (char *path)
 {
   WIN32_FIND_DATA data;
@@ -3082,7 +3082,7 @@ symlink_info::case_check (char *path)
       /* If that part of the component exists, check the case. */
       if (strcmp (c, data.cFileName))
        {
-         case_clash = TRUE;
+         case_clash = true;
 
          /* If check is set to STRICT, a wrong case results
             in returning a ENOENT. */
@@ -3094,7 +3094,7 @@ symlink_info::case_check (char *path)
          strcpy (c, data.cFileName);
        }
     }
-  return TRUE;
+  return true;
 }
 
 /* readlink system call */
index b1d1a27..92cd2b8 100644 (file)
@@ -101,7 +101,7 @@ class path_conv
   char *known_suffix;
   int error;
   device dev;
-  BOOL case_clash;
+  bool case_clash;
 
   int isdisk () const { return path_flags & PATH_ISDISK;}
   bool& isremote () {return fs.is_remote_drive ();}
@@ -183,7 +183,7 @@ class path_conv
   DWORD file_attributes () {return fileattr;}
   DWORD drive_type () {return fs.drive_type ();}
   DWORD fs_flags () {return fs.flags ();}
-  BOOL fs_fast_ea () {return fs.sym_opt () & PC_CHECK_EA;}
+  bool fs_fast_ea () {return !!(fs.sym_opt () & PC_CHECK_EA);}
   void set_path (const char *p) {strcpy (path, p);}
   const char * root_dir () const { return fs.root_dir (); }
   DWORD volser () { return fs.serial (); }
index a0419c8..b0f58b4 100644 (file)
@@ -254,6 +254,36 @@ pinfo::set_acl()
     debug_printf ("SetKernelObjectSecurity %E");
 }
 
+void
+_pinfo::set_ctty (tty_min *tc, int flags, fhandler_tty_slave *fhctty)
+{
+  int initial_ctty = ctty;
+  if ((ctty < 0 || ctty == tc->ntty) && !(flags & O_NOCTTY))
+    {
+      ctty = tc->ntty;
+      syscall_printf ("attached tty%d sid %d, pid %d, tty->pgid %d, tty->sid %d",
+                     tc->ntty, sid, pid, pgid, tc->getsid ());
+
+      pinfo p (tc->getsid ());
+      if (sid == pid && (!p || p->pid == pid || !proc_exists (p)))
+       {
+         paranoid_printf ("resetting tty%d sid.  Was %d, now %d.  pgid was %d, now %d.",
+                          tc->ntty, tc->getsid (), sid, tc->getpgid (), pgid);
+         /* We are the session leader */
+         tc->setsid (sid);
+         tc->setpgid (pgid);
+       }
+      else
+       sid = tc->getsid ();
+      if (tc->getpgid () == 0)
+       tc->setpgid (pgid);
+      if (fhctty)
+       cygheap->ctty  = *fhctty;
+      else if (initial_ctty < 0)
+       assert (cygheap->ctty.get_io_handle () == NULL);
+    }
+}
+
 bool
 _pinfo::alive ()
 {
index 1fd222b..f411b8c 100644 (file)
@@ -1,6 +1,6 @@
 /* pinfo.h: process table info
 
-   Copyright 2000, 2001, 2002 Red Hat, Inc.
+   Copyright 2000, 2001, 2002, 2003 Red Hat, Inc.
 
 This file is part of Cygwin.
 
@@ -112,6 +112,7 @@ public:
   commune_result commune_send (DWORD, ...);
   bool alive ();
   char *cmdline (size_t &);
+  void set_ctty (class tty_min *, int, class fhandler_tty_slave * = NULL);
 
   friend void __stdcall set_myself (pid_t, HANDLE);
 
index a93a6a6..4d0f408 100644 (file)
@@ -352,7 +352,7 @@ getacl (const char *file, DWORD attr, int nentries, __aclent32_t *aclbufp)
              id = ILLEGAL_GID;
            }
          else
-           id = ace_sid.get_id (TRUE, &type);
+           id = ace_sid.get_id (true, &type);
 
          if (!type)
            continue;
@@ -516,16 +516,16 @@ facl32 (int fd, int cmd, int nentries, __aclent32_t *aclbufp)
 extern "C" int
 aclcheck32 (__aclent32_t *aclbufp, int nentries, int *which)
 {
-  BOOL has_user_obj = FALSE;
-  BOOL has_group_obj = FALSE;
-  BOOL has_other_obj = FALSE;
-  BOOL has_class_obj = FALSE;
-  BOOL has_ug_objs = FALSE;
-  BOOL has_def_user_obj = FALSE;
-  BOOL has_def_group_obj = FALSE;
-  BOOL has_def_other_obj = FALSE;
-  BOOL has_def_class_obj = FALSE;
-  BOOL has_def_ug_objs = FALSE;
+  bool has_user_obj = false;
+  bool has_group_obj = false;
+  bool has_other_obj = false;
+  bool has_class_obj = false;
+  bool has_ug_objs = false;
+  bool has_def_user_obj = false;
+  bool has_def_group_obj = false;
+  bool has_def_other_obj = false;
+  bool has_def_class_obj = false;
+  bool has_def_ug_objs = false;
   int pos2;
 
   for (int pos = 0; pos < nentries; ++pos)
@@ -538,7 +538,7 @@ aclcheck32 (__aclent32_t *aclbufp, int nentries, int *which)
              *which = pos;
            return USER_ERROR;
          }
-       has_user_obj = TRUE;
+       has_user_obj = true;
        break;
       case GROUP_OBJ:
        if (has_group_obj)
@@ -547,7 +547,7 @@ aclcheck32 (__aclent32_t *aclbufp, int nentries, int *which)
              *which = pos;
            return GRP_ERROR;
          }
-       has_group_obj = TRUE;
+       has_group_obj = true;
        break;
       case OTHER_OBJ:
        if (has_other_obj)
@@ -556,7 +556,7 @@ aclcheck32 (__aclent32_t *aclbufp, int nentries, int *which)
              *which = pos;
            return OTHER_ERROR;
          }
-       has_other_obj = TRUE;
+       has_other_obj = true;
        break;
       case CLASS_OBJ:
        if (has_class_obj)
@@ -565,7 +565,7 @@ aclcheck32 (__aclent32_t *aclbufp, int nentries, int *which)
              *which = pos;
            return CLASS_ERROR;
          }
-       has_class_obj = TRUE;
+       has_class_obj = true;
        break;
       case USER:
       case GROUP:
@@ -576,7 +576,7 @@ aclcheck32 (__aclent32_t *aclbufp, int nentries, int *which)
              *which = pos2;
            return DUPLICATE_ERROR;
          }
-       has_ug_objs = TRUE;
+       has_ug_objs = true;
        break;
       case DEF_USER_OBJ:
        if (has_def_user_obj)
@@ -585,7 +585,7 @@ aclcheck32 (__aclent32_t *aclbufp, int nentries, int *which)
              *which = pos;
            return USER_ERROR;
          }
-       has_def_user_obj = TRUE;
+       has_def_user_obj = true;
        break;
       case DEF_GROUP_OBJ:
        if (has_def_group_obj)
@@ -594,7 +594,7 @@ aclcheck32 (__aclent32_t *aclbufp, int nentries, int *which)
              *which = pos;
            return GRP_ERROR;
          }
-       has_def_group_obj = TRUE;
+       has_def_group_obj = true;
        break;
       case DEF_OTHER_OBJ:
        if (has_def_other_obj)
@@ -603,7 +603,7 @@ aclcheck32 (__aclent32_t *aclbufp, int nentries, int *which)
              *which = pos;
            return OTHER_ERROR;
          }
-       has_def_other_obj = TRUE;
+       has_def_other_obj = true;
        break;
       case DEF_CLASS_OBJ:
        if (has_def_class_obj)
@@ -612,7 +612,7 @@ aclcheck32 (__aclent32_t *aclbufp, int nentries, int *which)
              *which = pos;
            return CLASS_ERROR;
          }
-       has_def_class_obj = TRUE;
+       has_def_class_obj = true;
        break;
       case DEF_USER:
       case DEF_GROUP:
@@ -623,7 +623,7 @@ aclcheck32 (__aclent32_t *aclbufp, int nentries, int *which)
              *which = pos2;
            return DUPLICATE_ERROR;
          }
-       has_def_ug_objs = TRUE;
+       has_def_ug_objs = true;
        break;
       default:
        return ENTRY_ERROR;
@@ -781,13 +781,13 @@ acltotext32 (__aclent32_t *aclbufp, int aclcnt)
     }
   char buf[32000];
   buf[0] = '\0';
-  BOOL first = TRUE;
+  bool first = true;
 
   for (int pos = 0; pos < aclcnt; ++pos)
     {
       if (!first)
        strcat (buf, ",");
-      first = FALSE;
+      first = false;
       if (aclbufp[pos].a_type & ACL_DEFAULT)
        strcat (buf, "default");
       switch (aclbufp[pos].a_type)
index 9d81004..9683a5a 100644 (file)
@@ -418,7 +418,7 @@ init_global_security ()
     get_null_sd ();
 }
 
-BOOL
+bool
 sec_acl (PACL acl, bool original, bool admins, PSID sid1, PSID sid2, DWORD access2)
 {
   size_t acl_len = MAX_DACL_LEN(5);
@@ -428,7 +428,7 @@ sec_acl (PACL acl, bool original, bool admins, PSID sid1, PSID sid2, DWORD acces
   if (!InitializeAcl (acl, acl_len, ACL_REVISION))
     {
       debug_printf ("InitializeAcl %E");
-      return FALSE;
+      return false;
     }
   if (sid1)
     if (!AddAccessAllowedAce (acl, ACL_REVISION,
@@ -456,7 +456,7 @@ sec_acl (PACL acl, bool original, bool admins, PSID sid1, PSID sid2, DWORD acces
   else
     debug_printf ("FindFirstFreeAce %E");
 
-  return TRUE;
+  return true;
 }
 
 PSECURITY_ATTRIBUTES __stdcall
index 6a09340..1c34052 100644 (file)
@@ -261,7 +261,7 @@ get_lsa_srv_inf (LSA_HANDLE lsa, char *logonserver, char *domain)
 }
 #endif
 
-BOOL
+bool
 get_logon_server (const char *domain, char *server, WCHAR *wserver)
 {
   WCHAR wdomain[INTERNET_MAX_HOST_NAME_LENGTH + 1];
@@ -276,7 +276,7 @@ get_logon_server (const char *domain, char *server, WCHAR *wserver)
       server[0] = server[1] = '\\';
       if (wserver)
        sys_mbstowcs (wserver, server, INTERNET_MAX_HOST_NAME_LENGTH + 1);
-      return TRUE;
+      return true;
     }
 
   /* Try to get the primary domain controller for the domain */
@@ -288,13 +288,13 @@ get_logon_server (const char *domain, char *server, WCHAR *wserver)
        for (WCHAR *ptr1 = buf; (*wserver++ = *ptr1++);)
          ;
       NetApiBufferFree (buf);
-      return TRUE;
+      return true;
     }
   __seterrno_from_win_error (ret);
-  return FALSE;
+  return false;
 }
 
-static BOOL
+static bool
 get_user_groups (WCHAR *wlogonserver, cygsidlist &grp_list, char *user,
                 char *domain)
 {
@@ -338,36 +338,36 @@ get_user_groups (WCHAR *wlogonserver, cygsidlist &grp_list, char *user,
     }
 
   NetApiBufferFree (buf);
-  return TRUE;
+  return true;
 }
 
-static BOOL
+static bool
 is_group_member (WCHAR *wgroup, PSID pusersid, cygsidlist &grp_list)
 {
   LPLOCALGROUP_MEMBERS_INFO_0 buf;
   DWORD cnt, tot;
   NET_API_STATUS ret;
-  BOOL retval = FALSE;
+  bool retval = false;
 
   /* Members can be users or global groups */
   ret = NetLocalGroupGetMembers (NULL, wgroup, 0, (LPBYTE *) &buf,
                                 MAX_PREFERRED_LENGTH, &cnt, &tot, NULL);
   if (ret)
-    return FALSE;
+    return false;
 
   for (DWORD bidx = 0; !retval && bidx < cnt; ++bidx)
     if (EqualSid (pusersid, buf[bidx].lgrmi0_sid))
-      retval = TRUE;
+      retval = true;
     else
       for (int glidx = 0; !retval && glidx < grp_list.count; ++glidx)
        if (EqualSid (grp_list.sids[glidx], buf[bidx].lgrmi0_sid))
-         retval = TRUE;
+         retval = true;
 
   NetApiBufferFree (buf);
   return retval;
 }
 
-static BOOL
+static bool
 get_user_local_groups (cygsidlist &grp_list, PSID pusersid)
 {
   LPLOCALGROUP_INFO_0 buf;
@@ -379,7 +379,7 @@ get_user_local_groups (cygsidlist &grp_list, PSID pusersid)
   if (ret)
     {
       __seterrno_from_win_error (ret);
-      return FALSE;
+      return false;
     }
 
   char bgroup[INTERNET_MAX_HOST_NAME_LENGTH + GNLEN + 2];
@@ -392,7 +392,7 @@ get_user_local_groups (cygsidlist &grp_list, PSID pusersid)
       || !GetComputerNameA (lgroup, &(llen = INTERNET_MAX_HOST_NAME_LENGTH + 1)))
     {
       __seterrno ();
-      return FALSE;
+      return false;
     }
   bgroup[blen++] = lgroup[llen++] = '\\';
 
@@ -421,18 +421,18 @@ get_user_local_groups (cygsidlist &grp_list, PSID pusersid)
          grp_list += gsid;
       }
   NetApiBufferFree (buf);
-  return TRUE;
+  return true;
 }
 
-static BOOL
+static bool
 sid_in_token_groups (PTOKEN_GROUPS grps, cygsid &sid)
 {
   if (!grps)
-    return FALSE;
+    return false;
   for (DWORD i = 0; i < grps->GroupCount; ++i)
     if (sid == grps->Groups[i].Sid)
-      return TRUE;
-  return FALSE;
+      return true;
+  return false;
 }
 
 #if 0                          /* Unused */
@@ -529,11 +529,11 @@ get_token_group_sidlist (cygsidlist &grp_list, PTOKEN_GROUPS my_grps,
     }
 }
 
-static BOOL
+static bool
 get_initgroups_sidlist (cygsidlist &grp_list,
                        PSID usersid, PSID pgrpsid, struct passwd *pw,
                        PTOKEN_GROUPS my_grps, LUID auth_luid, int &auth_pos,
-                       BOOL &special_pgrp)
+                       bool &special_pgrp)
 {
   grp_list += well_known_world_sid;
   grp_list += well_known_authenticated_users_sid;
@@ -556,12 +556,12 @@ get_initgroups_sidlist (cygsidlist &grp_list,
        get_user_groups (wserver, grp_list, user, domain);
       get_unix_group_sidlist (pw, grp_list);
       if (!get_user_local_groups (grp_list, usersid))
-       return FALSE;
+       return false;
     }
   /* special_pgrp true if pgrpsid is not in normal groups */
   if ((special_pgrp = !grp_list.contains (pgrpsid)))
     grp_list += pgrpsid;
-  return TRUE;
+  return true;
 }
 
 static void
@@ -704,11 +704,11 @@ get_priv_list (LSA_HANDLE lsa, cygsid &usersid, cygsidlist &grp_list)
        except if the token is internal and the group is in the token SD
        (see create_token). In that latter case that group must match the
        requested primary group.  */
-BOOL
-verify_token (HANDLE token, cygsid &usersid, user_groups &groups, BOOL *pintern)
+bool
+verify_token (HANDLE token, cygsid &usersid, user_groups &groups, bool *pintern)
 {
   DWORD size;
-  BOOL intern = FALSE;
+  bool intern = false;
 
   if (pintern)
     {
@@ -725,7 +725,7 @@ verify_token (HANDLE token, cygsid &usersid, user_groups &groups, BOOL *pintern)
                            &tok_usersid, sizeof tok_usersid, &size))
     debug_printf ("GetTokenInformation(): %E");
   if (usersid != tok_usersid)
-    return FALSE;
+    return false;
 
   /* For an internal token, if setgroups was not called and if the sd group
      is not well_known_null_sid, it must match pgrpsid */
@@ -805,7 +805,7 @@ create_token (cygsid &usersid, user_groups &new_groups, struct passwd *pw)
     { sizeof sqos, SecurityImpersonation, SECURITY_STATIC_TRACKING, FALSE };
   OBJECT_ATTRIBUTES oa = { sizeof oa, 0, 0, 0, 0, &sqos };
   PSECURITY_ATTRIBUTES psa;
-  BOOL special_pgrp = FALSE;
+  bool special_pgrp = false;
   char sa_buf[1024];
   LUID auth_luid = SYSTEM_LUID;
   LARGE_INTEGER exp = { QuadPart:INT64_MAX };
@@ -1204,7 +1204,7 @@ write_sd (const char *file, security_descriptor &sd)
 
 static void
 get_attribute_from_acl (mode_t *attribute, PACL acl, PSID owner_sid,
-                       PSID group_sid, BOOL grp_member)
+                       PSID group_sid, bool grp_member)
 {
   ACCESS_ALLOWED_ACE *ace;
   int allow = 0;
@@ -1325,7 +1325,7 @@ get_info_from_sd (PSECURITY_DESCRIPTOR psd, mode_t *attribute,
 
   __uid32_t uid;
   __gid32_t gid;
-  BOOL grp_member = get_sids_info (owner_sid, group_sid, &uid, &gid);
+  bool grp_member = get_sids_info (owner_sid, group_sid, &uid, &gid);
   if (uidret)
     *uidret = uid;
   if (gidret)
@@ -1465,36 +1465,36 @@ get_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type,
   return -1;
 }
 
-BOOL
+bool
 add_access_allowed_ace (PACL acl, int offset, DWORD attributes,
                        PSID sid, size_t &len_add, DWORD inherit)
 {
   if (!AddAccessAllowedAce (acl, ACL_REVISION, attributes, sid))
     {
       __seterrno ();
-      return FALSE;
+      return false;
     }
   ACCESS_ALLOWED_ACE *ace;
   if (inherit && GetAce (acl, offset, (PVOID *) &ace))
     ace->Header.AceFlags |= inherit;
   len_add += sizeof (ACCESS_ALLOWED_ACE) - sizeof (DWORD) + GetLengthSid (sid);
-  return TRUE;
+  return true;
 }
 
-BOOL
+bool
 add_access_denied_ace (PACL acl, int offset, DWORD attributes,
                       PSID sid, size_t &len_add, DWORD inherit)
 {
   if (!AddAccessDeniedAce (acl, ACL_REVISION, attributes, sid))
     {
       __seterrno ();
-      return FALSE;
+      return false;
     }
   ACCESS_DENIED_ACE *ace;
   if (inherit && GetAce (acl, offset, (PVOID *) &ace))
     ace->Header.AceFlags |= inherit;
   len_add += sizeof (ACCESS_DENIED_ACE) - sizeof (DWORD) + GetLengthSid (sid);
-  return TRUE;
+  return true;
 }
 
 static PSECURITY_DESCRIPTOR
@@ -1640,7 +1640,7 @@ alloc_sd (__uid32_t uid, __gid32_t gid, int attribute,
 
   /* Add owner and group permissions if SIDs are equal
      and construct deny attributes for group and owner. */
-  BOOL isownergroup;
+  bool isownergroup;
   if ((isownergroup = (owner_sid == group_sid)))
     owner_allow |= group_allow;
 
index 5da8e3d..8e958ba 100644 (file)
@@ -248,8 +248,8 @@ int __stdcall get_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type, m
                                  __uid32_t * = NULL, __gid32_t * = NULL);
 LONG __stdcall read_sd (const char *file, security_descriptor &sd);
 LONG __stdcall write_sd (const char *file, security_descriptor &sd);
-BOOL __stdcall add_access_allowed_ace (PACL acl, int offset, DWORD attributes, PSID sid, size_t &len_add, DWORD inherit);
-BOOL __stdcall add_access_denied_ace (PACL acl, int offset, DWORD attributes, PSID sid, size_t &len_add, DWORD inherit);
+bool __stdcall add_access_allowed_ace (PACL acl, int offset, DWORD attributes, PSID sid, size_t &len_add, DWORD inherit);
+bool __stdcall add_access_denied_ace (PACL acl, int offset, DWORD attributes, PSID sid, size_t &len_add, DWORD inherit);
 int __stdcall check_file_access (const char *, int);
 
 void set_security_attribute (int attribute, PSECURITY_ATTRIBUTES psa,
@@ -262,12 +262,12 @@ HANDLE subauth (struct passwd *pw);
 /* Try creating a token directly. */
 HANDLE create_token (cygsid &usersid, user_groups &groups, struct passwd * pw);
 /* Verify an existing token */
-BOOL verify_token (HANDLE token, cygsid &usersid, user_groups &groups, BOOL * pintern = NULL);
+bool verify_token (HANDLE token, cygsid &usersid, user_groups &groups, bool *pintern = NULL);
 
 /* Extract U-domain\user field from passwd entry. */
 void extract_nt_dom_user (const struct passwd *pw, char *domain, char *user);
 /* Get default logonserver for a domain. */
-BOOL get_logon_server (const char * domain, char * server, WCHAR *wserver = NULL);
+bool get_logon_server (const char * domain, char * server, WCHAR *wserver = NULL);
 
 /* sec_helper.cc: Security helper functions. */
 int set_process_privilege (const char *privilege, bool enable = true, bool use_thread = false);
@@ -281,7 +281,7 @@ extern SECURITY_ATTRIBUTES sec_none, sec_none_nih, sec_all, sec_all_nih;
 extern SECURITY_ATTRIBUTES *__stdcall __sec_user (PVOID sa_buf, PSID sid1, PSID sid2, 
                                                  DWORD access2, BOOL inherit)
   __attribute__ ((regparm (3)));
-extern BOOL sec_acl (PACL acl, bool original, bool admins, PSID sid1 = NO_SID, 
+extern bool sec_acl (PACL acl, bool original, bool admins, PSID sid1 = NO_SID, 
                     PSID sid2 = NO_SID, DWORD access2 = 0);
 
 int __stdcall NTReadEA (const char *file, const char *attrname, char *buf, int len);
index 7203e0c..f962934 100644 (file)
@@ -281,7 +281,7 @@ select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
 
       select_printf ("woke up.  wait_ret %d.  verifying", wait_ret);
       s = &start;
-      int gotone = FALSE;
+      bool gotone = false;
       /* Some types of object (e.g., consoles) wake up on "inappropriate" events
         like mouse movements.  The verify function will detect these situations.
         If it returns false, then this wakeup was a false alarm and we should go
@@ -511,7 +511,7 @@ static int start_thread_pipe (select_record *me, select_stuff *stuff);
 struct pipeinf
   {
     cygthread *thread;
-    BOOL stop_thread_pipe;
+    bool stop_thread_pipe;
     select_record *start;
   };
 
@@ -519,7 +519,7 @@ static DWORD WINAPI
 thread_pipe (void *arg)
 {
   pipeinf *pi = (pipeinf *) arg;
-  BOOL gotone = FALSE;
+  bool gotone = false;
 
   for (;;)
     {
@@ -559,7 +559,7 @@ start_thread_pipe (select_record *me, select_stuff *stuff)
     }
   pipeinf *pi = new pipeinf;
   pi->start = &stuff->start;
-  pi->stop_thread_pipe = FALSE;
+  pi->stop_thread_pipe = false;
   pi->thread = new cygthread (thread_pipe, (LPVOID) pi, "select_pipe");
   me->h = *pi->thread;
   if (!me->h)
@@ -848,7 +848,7 @@ static int start_thread_serial (select_record *me, select_stuff *stuff);
 struct serialinf
   {
     cygthread *thread;
-    BOOL stop_thread_serial;
+    bool stop_thread_serial;
     select_record *start;
   };
 
@@ -956,7 +956,7 @@ static DWORD WINAPI
 thread_serial (void *arg)
 {
   serialinf *si = (serialinf *) arg;
-  BOOL gotone= FALSE;
+  bool gotone = false;
 
   for (;;)
     {
@@ -990,7 +990,7 @@ start_thread_serial (select_record *me, select_stuff *stuff)
     }
   serialinf *si = new serialinf;
   si->start = &stuff->start;
-  si->stop_thread_serial = FALSE;
+  si->stop_thread_serial = false;
   si->thread = new cygthread (thread_serial, (LPVOID) si, "select_serial");
   me->h = *si->thread;
   stuff->device_specific_serial = (void *) si;
index b4a9ee1..026e847 100644 (file)
@@ -163,7 +163,7 @@ DWORD NO_COPY sigtid = 0;           // ID of the signal thread
 /* Functions
  */
 static int __stdcall checkstate (waitq *) __attribute__ ((regparm (1)));
-static __inline__ BOOL get_proc_lock (DWORD, DWORD);
+static __inline__ bool get_proc_lock (DWORD, DWORD);
 static void __stdcall remove_zombie (int);
 static DWORD WINAPI wait_sig (VOID *arg);
 static int __stdcall stopped_or_terminated (waitq *, _pinfo *);
@@ -172,14 +172,14 @@ static DWORD WINAPI wait_subproc (VOID *);
 /* Determine if the parent process is alive.
  */
 
-BOOL __stdcall
+bool __stdcall
 my_parent_is_alive ()
 {
-  DWORD res;
+  bool res;
   if (!myself->ppid_handle)
     {
       debug_printf ("No myself->ppid_handle");
-      res = FALSE;
+      res = false;
     }
   else
     for (int i = 0; i < 2; i++)
@@ -187,11 +187,11 @@ my_parent_is_alive ()
        {
          case WAIT_OBJECT_0:
            debug_printf ("parent dead.");
-           res = FALSE;
+           res = false;
            goto out;
          case WAIT_TIMEOUT:
            debug_printf ("parent still alive");
-           res = TRUE;
+           res = true;
            goto out;
          case WAIT_FAILED:
            DWORD werr = GetLastError ();
@@ -199,7 +199,7 @@ my_parent_is_alive ()
              continue;
            system_printf ("WFSO for myself->ppid_handle(%p) failed, error %d",
                           myself->ppid_handle, werr);
-           res = FALSE;
+           res = false;
            goto out;
        }
 out:
@@ -221,31 +221,31 @@ wait_for_sigthread ()
  * Attempt to handle case where process is exiting as we try to grab
  * the mutex.
  */
-static BOOL
+static bool
 get_proc_lock (DWORD what, DWORD val)
 {
   Static int lastwhat = -1;
   if (!sync_proc_subproc)
-    return FALSE;
+    return false;
   if (sync_proc_subproc->acquire (WPSP))
     {
       lastwhat = what;
-      return TRUE;
+      return true;
     }
   if (!sync_proc_subproc)
-    return FALSE;
+    return false;
   system_printf ("Couldn't aquire sync_proc_subproc for(%d,%d), %E, last %d",
                  what, val, lastwhat);
-  return TRUE;
+  return true;
 }
 
-static BOOL __stdcall
+static bool __stdcall
 proc_can_be_signalled (_pinfo *p)
 {
   if (p == myself_nowait || p == myself)
     {
       assert (!wait_sig_inited);
-      return 1;
+      return true;
     }
 
   return ISSTATE (p, PID_INITIALIZING) ||
@@ -253,7 +253,7 @@ proc_can_be_signalled (_pinfo *p)
          (PID_ACTIVE | PID_IN_USE));
 }
 
-BOOL __stdcall
+bool __stdcall
 pid_exists (pid_t pid)
 {
   pinfo p (pid);
@@ -262,7 +262,7 @@ pid_exists (pid_t pid)
 
 /* Test to determine if a process really exists and is processing signals.
  */
-BOOL __stdcall
+bool __stdcall
 proc_exists (_pinfo *p)
 {
   return p && !(p->process_state & (PID_EXITED | PID_ZOMBIE));
@@ -654,7 +654,7 @@ int __stdcall
 sig_send (_pinfo *p, int sig, void *tls)
 {
   int rc = 1;
-  BOOL its_me;
+  bool its_me;
   HANDLE sendsig;
   sigpacket pack;
 
@@ -925,7 +925,7 @@ stopped_or_terminated (waitq *parent_w, _pinfo *child)
   if (!potential_match)
     return 0;
 
-  BOOL terminated;
+  bool terminated;
 
   if ((terminated = child->process_state == PID_ZOMBIE) ||
       ((w->options & WUNTRACED) && child->stopsig))
index f55618b..30ce799 100644 (file)
@@ -51,7 +51,7 @@ typedef struct struct_waitq
 extern HANDLE signal_arrived;
 extern HANDLE sigCONT;
 
-BOOL __stdcall my_parent_is_alive ();
+bool __stdcall my_parent_is_alive ();
 int __stdcall sig_dispatch_pending ();
 #ifdef _PINFO_H
 extern "C" void __stdcall set_signal_mask (sigset_t newmask, sigset_t& = myself->getsigmask ());
@@ -76,8 +76,8 @@ void __stdcall proc_terminate ();
 void __stdcall sigproc_init ();
 void __stdcall subproc_init ();
 void __stdcall sigproc_terminate ();
-BOOL __stdcall proc_exists (_pinfo *) __attribute__ ((regparm(1)));
-BOOL __stdcall pid_exists (pid_t) __attribute__ ((regparm(1)));
+bool __stdcall proc_exists (_pinfo *) __attribute__ ((regparm(1)));
+bool __stdcall pid_exists (pid_t) __attribute__ ((regparm(1)));
 int __stdcall sig_send (_pinfo *, int, void * = NULL) __attribute__ ((regparm(3)));
 void __stdcall signal_fixup_after_fork ();
 void __stdcall signal_fixup_after_exec ();
index b22e8c7..11a3616 100644 (file)
@@ -345,11 +345,11 @@ do_cleanup (void *args)
 }
 
 
-static int __stdcall
+static bool __stdcall
 spawn_guts (const char * prog_arg, const char *const *argv,
            const char *const envp[], int mode)
 {
-  BOOL rc;
+  bool rc;
   pid_t cygpid;
 
   MALLOC_CHECK;
@@ -832,10 +832,10 @@ spawn_guts (const char * prog_arg, const char *const *argv,
 
   sigproc_printf ("spawned windows pid %d", pi.dwProcessId);
 
-  BOOL exited;
+  bool exited;
 
   res = 0;
-  exited = FALSE;
+  exited = false;
   MALLOC_CHECK;
   if (mode == _P_OVERLAY)
     {
@@ -851,7 +851,7 @@ spawn_guts (const char * prog_arg, const char *const *argv,
              if (!GetExitCodeProcess (pi.hProcess, &exitcode))
                exitcode = 1;
              res |= exitcode;
-             exited = TRUE;
+             exited = true;
              break;
            case WAIT_OBJECT_0 + 1:
              sigproc_printf ("signal arrived");
index fc0fe58..4c0f08e 100644 (file)
@@ -117,7 +117,7 @@ strace::vsprntf (char *buf, const char *func, const char *infmt, va_list ap)
 {
   int count;
   char fmt[80];
-  static NO_COPY int nonewline = FALSE;
+  static NO_COPY bool nonewline = false;
   DWORD err = GetLastError ();
   const char *tn = cygthread::name ();
   char *pn = __progname ?: (myself ? myself->progname : NULL);
@@ -163,7 +163,7 @@ strace::vsprntf (char *buf, const char *func, const char *infmt, va_list ap)
          break;
        case '\b':
          *--p = '\0';
-          nonewline = TRUE;
+          nonewline = true;
          goto done;
        default:
          goto addnl;
@@ -172,7 +172,7 @@ strace::vsprntf (char *buf, const char *func, const char *infmt, va_list ap)
 addnl:
   *p++ = '\n';
   *p = '\0';
-  nonewline = FALSE;
+  nonewline = false;
 
 done:
   return p - buf;
index f45308b..c857ed4 100644 (file)
@@ -317,6 +317,11 @@ setsid (void)
       myself->ctty = -1;
       myself->sid = getpid ();
       myself->pgid = getpid ();
+      if (cygheap->ctty.get_io_handle ())
+       {
+         cygheap->ctty.close ();
+         cygheap->ctty.set_io_handle (NULL);
+       }
       syscall_printf ("sid %d, pgid %d, ctty %d, open_fhs %d", myself->sid,
                      myself->pgid, myself->ctty, fhandler_console::open_fhs);
       return myself->sid;
@@ -652,7 +657,7 @@ link (const char *a, const char *b)
   int res = -1;
   path_conv real_a (a, PC_SYM_NOFOLLOW | PC_FULL);
   path_conv real_b (b, PC_SYM_NOFOLLOW | PC_FULL);
-  extern BOOL allow_winsymlinks;
+  extern bool allow_winsymlinks;
 
   if (real_a.error)
     {
@@ -2096,7 +2101,7 @@ seteuid32 (__uid32_t uid)
   user_groups &groups = cygheap->user.groups;
   HANDLE ptok, new_token = INVALID_HANDLE_VALUE;
   struct passwd * pw_new;
-  BOOL token_is_internal, issamesid;
+  bool token_is_internal, issamesid;
   char dacl_buf[MAX_DACL_LEN (5)];
   TOKEN_DEFAULT_DACL tdacl = {};
 
index c034dfe..07c7a0a 100644 (file)
@@ -294,19 +294,19 @@ tty_list::allocate_tty (int with_console)
   return freetty;
 }
 
-BOOL
+bool
 tty::slave_alive ()
 {
   return alive (TTY_SLAVE_ALIVE);
 }
 
-BOOL
+bool
 tty::master_alive ()
 {
   return alive (TTY_MASTER_ALIVE);
 }
 
-BOOL
+bool
 tty::alive (const char *fmt)
 {
   HANDLE ev;
@@ -362,25 +362,25 @@ tty::get_event (const char *fmt, BOOL manual_reset)
   return hev;
 }
 
-int
+bool
 tty::make_pipes (fhandler_pty_master *ptym)
 {
   /* Create communication pipes */
 
   /* FIXME: should this be sec_none_nih? */
-  if (CreatePipe (&from_master, &to_slave, &sec_all, 128 * 1024) == FALSE)
+  if (!CreatePipe (&from_master, &to_slave, &sec_all, 128 * 1024))
     {
       termios_printf ("can't create input pipe");
       set_errno (ENOENT);
-      return FALSE;
+      return false;
     }
 
   // ProtectHandle1INH (to_slave, to_pty);
-  if (CreatePipe (&from_slave, &to_master, &sec_all, 128 * 1024) == FALSE)
+  if (!CreatePipe (&from_slave, &to_master, &sec_all, 128 * 1024))
     {
       termios_printf ("can't create output pipe");
       set_errno (ENOENT);
-      return FALSE;
+      return false;
     }
   // ProtectHandle1INH (from_slave, from_pty);
   termios_printf ("tty%d from_slave %p, to_slave %p", ntty, from_slave,
@@ -391,44 +391,34 @@ tty::make_pipes (fhandler_pty_master *ptym)
     termios_printf ("can't set to_slave to non-blocking mode");
   ptym->set_io_handle (from_slave);
   ptym->set_output_handle (to_slave);
-  return TRUE;
+  return true;
 }
 
-BOOL
+bool
 tty::common_init (fhandler_pty_master *ptym)
 {
   /* Set termios information.  Force initialization. */
-  ptym->tcinit (this, TRUE);
+  ptym->tcinit (this, true);
 
   if (!make_pipes (ptym))
-    return FALSE;
+    return false;
   ptym->need_nl = 0;
 
   /* Save our pid  */
 
   master_pid = GetCurrentProcessId ();
 
-  /* Allow the others to open us (for handle duplication) */
+  /* We do not open allow the others to open us (for handle duplication)
+     but rely on cygheap->inherited_ctty for descendant processes.
+     In the future the cygserver may allow access by others. */
 
-  /* FIXME: we shold NOT set the security wide open when the
-     daemon is running
-   */
+#ifdef USE_SERVER
   if (wincap.has_security ())
     {
-#ifdef USE_SERVER
       if (cygserver_running == CYGSERVER_UNKNOWN)
        cygserver_init ();
-#endif
-
-      if (
-#ifdef USE_SERVER
-         cygserver_running != CYGSERVER_OK &&
-#endif
-         !SetKernelObjectSecurity (hMainProc,
-                                      DACL_SECURITY_INFORMATION,
-                                      get_null_sd ()))
-       system_printf ("Can't set process security, %E");
     }
+#endif
 
   /* Create synchronisation events */
 
@@ -440,15 +430,15 @@ tty::common_init (fhandler_pty_master *ptym)
   else
     {
       if (!(ptym->output_done_event = get_event (OUTPUT_DONE_EVENT)))
-       return FALSE;
+       return false;
       if (!(ptym->ioctl_done_event = get_event (IOCTL_DONE_EVENT)))
-       return FALSE;
+       return false;
       if (!(ptym->ioctl_request_event = get_event (IOCTL_REQUEST_EVENT)))
-       return FALSE;
+       return false;
     }
 
   if (!(ptym->input_available_event = get_event (INPUT_AVAILABLE_EVENT, TRUE)))
-    return FALSE;
+    return false;
 
   char buf[40];
   __small_sprintf (buf, OUTPUT_MUTEX, ntty);
@@ -456,7 +446,7 @@ tty::common_init (fhandler_pty_master *ptym)
     {
       termios_printf ("can't create %s", buf);
       set_errno (ENOENT);
-      return FALSE;
+      return false;
     }
 
   __small_sprintf (buf, INPUT_MUTEX, ntty);
@@ -464,7 +454,7 @@ tty::common_init (fhandler_pty_master *ptym)
     {
       termios_printf ("can't create %s", buf);
       set_errno (ENOENT);
-      return FALSE;
+      return false;
     }
 
   ProtectHandle1INH (ptym->output_mutex, output_mutex);
@@ -473,5 +463,5 @@ tty::common_init (fhandler_pty_master *ptym)
   winsize.ws_row = 25;
 
   termios_printf ("tty%d opened", ntty);
-  return TRUE;
+  return true;
 }
index 30d8bb0..8153aaf 100644 (file)
@@ -61,7 +61,6 @@ public:
   void setpgid (int pid) {pgid = pid;}
   int getsid () {return sid;}
   void setsid (pid_t tsid) {sid = tsid;}
-  void set_ctty (int ttynum, int flags);
   void kill_pgrp (int sig);
   struct termios ti;
   struct winsize winsize;
@@ -98,17 +97,17 @@ public:
   HANDLE from_slave, to_master;
 
   int read_retval;
-  BOOL was_opened;     /* True if opened at least once. */
+  bool was_opened;     /* True if opened at least once. */
 
   void init ();
   HANDLE create_inuse (const char *);
-  BOOL common_init (fhandler_pty_master *);
-  BOOL alive (const char *fmt);
-  BOOL slave_alive ();
-  BOOL master_alive ();
+  bool common_init (fhandler_pty_master *);
+  bool alive (const char *fmt);
+  bool slave_alive ();
+  bool master_alive ();
   HWND gethwnd () {return hwnd;}
   void sethwnd (HWND wnd) {hwnd = wnd;}
-  int make_pipes (fhandler_pty_master *ptym);
+  bool make_pipes (fhandler_pty_master *ptym);
   HANDLE open_output_mutex ()
   {
     char buf[80];
@@ -121,7 +120,7 @@ public:
     __small_sprintf (buf, INPUT_MUTEX, ntty);
     return OpenMutex (MUTEX_ALL_ACCESS, TRUE, buf);
   }
-  BOOL exists ()
+  bool exists ()
   {
     HANDLE h = open_output_mutex ();
     if (h)