* fhandler.cc (fhandler_base::set_no_inheritance): Always use
SetHandleInformation. * fhandler_disk_file.cc (fhandler_disk_file::lock): Always use UnlockFileEx/LockFileEx functions. * net.cc (fdsock): Don't bother to duplicate socket for inheritance. * sysconf.cc (get_nproc_values): Take NT for granted. (get_avphys): Ditto. * syslog.cc (WIN95_EVENT_LOG_PATH): Remove define. (get_win95_event_log_path): Remove. (vsyslog): Fix formatting. Take NT for granted. * wincap.cc: Remove has_lock_file_ex, has_signal_object_and_wait, has_eventlog, has_set_handle_information, has_set_handle_information_on_console_handles and supports_smp throughout. * wincap.h: Ditto.
This commit is contained in:
parent
64f211c87c
commit
eef57fe1e3
|
@ -1,3 +1,21 @@
|
|||
2007-02-22 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* fhandler.cc (fhandler_base::set_no_inheritance): Always use
|
||||
SetHandleInformation.
|
||||
* fhandler_disk_file.cc (fhandler_disk_file::lock): Always use
|
||||
UnlockFileEx/LockFileEx functions.
|
||||
* net.cc (fdsock): Don't bother to duplicate socket for inheritance.
|
||||
* sysconf.cc (get_nproc_values): Take NT for granted.
|
||||
(get_avphys): Ditto.
|
||||
* syslog.cc (WIN95_EVENT_LOG_PATH): Remove define.
|
||||
(get_win95_event_log_path): Remove.
|
||||
(vsyslog): Fix formatting. Take NT for granted.
|
||||
* wincap.cc: Remove has_lock_file_ex, has_signal_object_and_wait,
|
||||
has_eventlog, has_set_handle_information,
|
||||
has_set_handle_information_on_console_handles and supports_smp
|
||||
throughout.
|
||||
* wincap.h: Ditto.
|
||||
|
||||
2007-02-22 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* dir.cc (rmdir): Move existance check in front of
|
||||
|
|
|
@ -1481,21 +1481,9 @@ fhandler_dev_null::open (int flags, mode_t mode)
|
|||
void
|
||||
fhandler_base::set_no_inheritance (HANDLE &h, bool not_inheriting)
|
||||
{
|
||||
if (wincap.has_set_handle_information ())
|
||||
{
|
||||
if (!SetHandleInformation (h, HANDLE_FLAG_INHERIT, not_inheriting ? 0 : HANDLE_FLAG_INHERIT))
|
||||
debug_printf ("SetHandleInformation failed, %E");
|
||||
}
|
||||
else
|
||||
{
|
||||
HANDLE oh = h;
|
||||
if (!DuplicateHandle (hMainProc, oh, hMainProc, &h, 0, !not_inheriting,
|
||||
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
|
||||
debug_printf ("DuplicateHandle failed, %E");
|
||||
|
||||
if (oh != h)
|
||||
VerifyHandle (h);
|
||||
}
|
||||
if (!SetHandleInformation (h, HANDLE_FLAG_INHERIT,
|
||||
not_inheriting ? 0 : HANDLE_FLAG_INHERIT))
|
||||
debug_printf ("SetHandleInformation failed, %E");
|
||||
#ifdef DEBUGGING_AND_FDS_PROTECTED
|
||||
if (h)
|
||||
setclexec (oh, h, not_inheriting);
|
||||
|
|
|
@ -1281,49 +1281,38 @@ fhandler_disk_file::lock (int cmd, struct __flock64 *fl)
|
|||
|
||||
BOOL res;
|
||||
|
||||
if (wincap.has_lock_file_ex ())
|
||||
DWORD lock_flags = (cmd == F_SETLK) ? LOCKFILE_FAIL_IMMEDIATELY : 0;
|
||||
lock_flags |= (fl->l_type == F_WRLCK) ? LOCKFILE_EXCLUSIVE_LOCK : 0;
|
||||
|
||||
OVERLAPPED ov;
|
||||
|
||||
ov.Internal = 0;
|
||||
ov.InternalHigh = 0;
|
||||
ov.Offset = off_low;
|
||||
ov.OffsetHigh = off_high;
|
||||
ov.hEvent = (HANDLE) 0;
|
||||
|
||||
if (fl->l_type == F_UNLCK)
|
||||
{
|
||||
DWORD lock_flags = (cmd == F_SETLK) ? LOCKFILE_FAIL_IMMEDIATELY : 0;
|
||||
lock_flags |= (fl->l_type == F_WRLCK) ? LOCKFILE_EXCLUSIVE_LOCK : 0;
|
||||
|
||||
OVERLAPPED ov;
|
||||
|
||||
ov.Internal = 0;
|
||||
ov.InternalHigh = 0;
|
||||
ov.Offset = off_low;
|
||||
ov.OffsetHigh = off_high;
|
||||
ov.hEvent = (HANDLE) 0;
|
||||
|
||||
if (fl->l_type == F_UNLCK)
|
||||
{
|
||||
res = UnlockFileEx (get_handle (), 0, len_low, len_high, &ov);
|
||||
if (res == 0 && GetLastError () == ERROR_NOT_LOCKED)
|
||||
res = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = LockFileEx (get_handle (), lock_flags, 0,
|
||||
len_low, len_high, &ov);
|
||||
/* Deal with the fail immediately case. */
|
||||
/*
|
||||
* FIXME !! I think this is the right error to check for
|
||||
* but I must admit I haven't checked....
|
||||
*/
|
||||
if ((res == 0) && (lock_flags & LOCKFILE_FAIL_IMMEDIATELY) &&
|
||||
(GetLastError () == ERROR_LOCK_FAILED))
|
||||
{
|
||||
set_errno (EAGAIN);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
res = UnlockFileEx (get_handle (), 0, len_low, len_high, &ov);
|
||||
if (res == 0 && GetLastError () == ERROR_NOT_LOCKED)
|
||||
res = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Windows 95 -- use primitive lock call */
|
||||
if (fl->l_type == F_UNLCK)
|
||||
res = UnlockFile (get_handle (), off_low, off_high, len_low, len_high);
|
||||
else
|
||||
res = LockFile (get_handle (), off_low, off_high, len_low, len_high);
|
||||
res = LockFileEx (get_handle (), lock_flags, 0,
|
||||
len_low, len_high, &ov);
|
||||
/* Deal with the fail immediately case. */
|
||||
/*
|
||||
* FIXME !! I think this is the right error to check for
|
||||
* but I must admit I haven't checked....
|
||||
*/
|
||||
if ((res == 0) && (lock_flags & LOCKFILE_FAIL_IMMEDIATELY) &&
|
||||
(GetLastError () == ERROR_LOCK_FAILED))
|
||||
{
|
||||
set_errno (EAGAIN);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (res == 0)
|
||||
|
|
|
@ -501,16 +501,6 @@ cygwin_getprotobynumber (int number)
|
|||
bool
|
||||
fdsock (cygheap_fdmanip& fd, const device *dev, SOCKET soc)
|
||||
{
|
||||
/* NT systems apparently set sockets to inheritable by default */
|
||||
if (!wincap.has_set_handle_information ()
|
||||
&& !DuplicateHandle (hMainProc, (HANDLE) soc,
|
||||
hMainProc, (HANDLE *) &soc,
|
||||
0, TRUE,
|
||||
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
|
||||
{
|
||||
debug_printf ("set socket inheritance failed, %E");
|
||||
return false;
|
||||
}
|
||||
fd = build_fh_dev (*dev);
|
||||
if (!fd.isopen ())
|
||||
return false;
|
||||
|
|
|
@ -40,46 +40,32 @@ get_page_size (int in)
|
|||
static long
|
||||
get_nproc_values (int in)
|
||||
{
|
||||
NTSTATUS ret;
|
||||
SYSTEM_BASIC_INFORMATION sbi;
|
||||
if ((ret = NtQuerySystemInformation (SystemBasicInformation, (PVOID) &sbi,
|
||||
sizeof sbi, NULL)) != STATUS_SUCCESS)
|
||||
{
|
||||
__seterrno_from_nt_status (ret);
|
||||
debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %E",
|
||||
ret);
|
||||
return -1;
|
||||
}
|
||||
switch (in)
|
||||
{
|
||||
case _SC_NPROCESSORS_CONF:
|
||||
return sbi.NumberProcessors;
|
||||
case _SC_NPROCESSORS_ONLN:
|
||||
if (!wincap.supports_smp ())
|
||||
return 1;
|
||||
/*FALLTHRU*/
|
||||
{
|
||||
int i = 0;
|
||||
do
|
||||
if (sbi.ActiveProcessors & 1)
|
||||
i++;
|
||||
while (sbi.ActiveProcessors >>= 1);
|
||||
return i;
|
||||
}
|
||||
case _SC_PHYS_PAGES:
|
||||
if (wincap.supports_smp ())
|
||||
{
|
||||
NTSTATUS ret;
|
||||
SYSTEM_BASIC_INFORMATION sbi;
|
||||
if ((ret = NtQuerySystemInformation (SystemBasicInformation,
|
||||
(PVOID) &sbi,
|
||||
sizeof sbi, NULL))
|
||||
!= STATUS_SUCCESS)
|
||||
{
|
||||
__seterrno_from_nt_status (ret);
|
||||
debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %E",
|
||||
ret);
|
||||
return -1;
|
||||
}
|
||||
switch (in)
|
||||
{
|
||||
case _SC_NPROCESSORS_CONF:
|
||||
return sbi.NumberProcessors;
|
||||
case _SC_NPROCESSORS_ONLN:
|
||||
{
|
||||
int i = 0;
|
||||
do
|
||||
if (sbi.ActiveProcessors & 1)
|
||||
i++;
|
||||
while (sbi.ActiveProcessors >>= 1);
|
||||
return i;
|
||||
}
|
||||
case _SC_PHYS_PAGES:
|
||||
return sbi.NumberOfPhysicalPages
|
||||
/ (getpagesize () / getsystempagesize ());
|
||||
}
|
||||
}
|
||||
return sbi.NumberOfPhysicalPages
|
||||
/ (getpagesize () / getsystempagesize ());
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -87,23 +73,18 @@ get_nproc_values (int in)
|
|||
static long
|
||||
get_avphys (int in)
|
||||
{
|
||||
if (wincap.supports_smp ())
|
||||
NTSTATUS ret;
|
||||
SYSTEM_PERFORMANCE_INFORMATION spi;
|
||||
if ((ret = NtQuerySystemInformation (SystemPerformanceInformation,
|
||||
(PVOID) &spi, sizeof spi, NULL))
|
||||
!= STATUS_SUCCESS)
|
||||
{
|
||||
NTSTATUS ret;
|
||||
SYSTEM_PERFORMANCE_INFORMATION spi;
|
||||
if ((ret = NtQuerySystemInformation (SystemPerformanceInformation,
|
||||
(PVOID) &spi,
|
||||
sizeof spi, NULL))
|
||||
!= STATUS_SUCCESS)
|
||||
{
|
||||
__seterrno_from_nt_status (ret);
|
||||
debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %E",
|
||||
ret);
|
||||
return -1;
|
||||
}
|
||||
return spi.AvailablePages / (getpagesize () / getsystempagesize ());
|
||||
__seterrno_from_nt_status (ret);
|
||||
debug_printf ("NtQuerySystemInformation: ret %d, Dos(ret) %E",
|
||||
ret);
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
return spi.AvailablePages / (getpagesize () / getsystempagesize ());
|
||||
}
|
||||
|
||||
enum sc_type { nsup, cons, func };
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* syslog.cc
|
||||
|
||||
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
||||
2006 Red Hat, Inc.
|
||||
2006, 2007 Red Hat, Inc.
|
||||
|
||||
This file is part of Cygwin.
|
||||
|
||||
|
@ -28,22 +28,8 @@ details. */
|
|||
#include "thread.h"
|
||||
#include "cygtls.h"
|
||||
|
||||
/* FIXME: These should probably be in the registry. */
|
||||
/* FIXME: The Win95 path should be whatever slash is */
|
||||
|
||||
#define WIN95_EVENT_LOG_PATH "C:\\CYGWIN_SYSLOG.TXT"
|
||||
#define CYGWIN_LOG_NAME "Cygwin"
|
||||
|
||||
/*
|
||||
* Utility function to help enable moving
|
||||
* WIN95_EVENT_LOG_PATH into registry later.
|
||||
*/
|
||||
static const char *
|
||||
get_win95_event_log_path ()
|
||||
{
|
||||
return WIN95_EVENT_LOG_PATH;
|
||||
}
|
||||
|
||||
/* openlog: save the passed args. Don't open the
|
||||
system log (NT) or log file (95) yet. */
|
||||
extern "C" void
|
||||
|
@ -286,212 +272,137 @@ try_connect_syslogd (int priority, const char *msg, int len)
|
|||
extern "C" void
|
||||
vsyslog (int priority, const char *message, va_list ap)
|
||||
{
|
||||
debug_printf ("%x %s", priority, message);
|
||||
/* If the priority fails the current mask, reject */
|
||||
if ((LOG_MASK (LOG_PRI (priority)) & _my_tls.locals.process_logmask) == 0)
|
||||
debug_printf ("%x %s", priority, message);
|
||||
/* If the priority fails the current mask, reject */
|
||||
if ((LOG_MASK (LOG_PRI (priority)) & _my_tls.locals.process_logmask) == 0)
|
||||
{
|
||||
debug_printf ("failing message %x due to priority mask %x",
|
||||
priority, _my_tls.locals.process_logmask);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Add default facility if not in the given priority. */
|
||||
if (!(priority & LOG_FACMASK))
|
||||
priority |= _my_tls.locals.process_facility;
|
||||
|
||||
/* Translate %m in the message to error text */
|
||||
char *errtext = strerror (get_errno ());
|
||||
int errlen = strlen (errtext);
|
||||
int numfound = 0;
|
||||
|
||||
for (const char *cp = message; *cp; cp++)
|
||||
if (*cp == '%' && cp[1] == 'm')
|
||||
numfound++;
|
||||
|
||||
char *newmessage = (char *) alloca (strlen (message) +
|
||||
(errlen * numfound) + 1);
|
||||
|
||||
if (newmessage == NULL)
|
||||
{
|
||||
debug_printf ("failed to allocate newmessage");
|
||||
return;
|
||||
}
|
||||
|
||||
char *dst = newmessage;
|
||||
for (const char *cp2 = message; *cp2; cp2++)
|
||||
if (*cp2 == '%' && cp2[1] == 'm')
|
||||
{
|
||||
debug_printf ("failing message %x due to priority mask %x",
|
||||
priority, _my_tls.locals.process_logmask);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Add default facility if not in the given priority. */
|
||||
if (!(priority & LOG_FACMASK))
|
||||
priority |= _my_tls.locals.process_facility;
|
||||
|
||||
/* Translate %m in the message to error text */
|
||||
char *errtext = strerror (get_errno ());
|
||||
int errlen = strlen (errtext);
|
||||
int numfound = 0;
|
||||
|
||||
for (const char *cp = message; *cp; cp++)
|
||||
if (*cp == '%' && cp[1] == 'm')
|
||||
numfound++;
|
||||
|
||||
char *newmessage = (char *) alloca (strlen (message) +
|
||||
(errlen * numfound) + 1);
|
||||
|
||||
if (newmessage == NULL)
|
||||
{
|
||||
debug_printf ("failed to allocate newmessage");
|
||||
return;
|
||||
}
|
||||
|
||||
char *dst = newmessage;
|
||||
for (const char *cp2 = message; *cp2; cp2++)
|
||||
if (*cp2 == '%' && cp2[1] == 'm')
|
||||
{
|
||||
cp2++;
|
||||
strcpy (dst, errtext);
|
||||
while (*dst)
|
||||
dst++;
|
||||
}
|
||||
else
|
||||
*dst++ = *cp2;
|
||||
|
||||
*dst = '\0';
|
||||
message = newmessage;
|
||||
|
||||
/* Work out the priority type - we ignore the facility for now.. */
|
||||
WORD eventType;
|
||||
switch (LOG_PRI (priority))
|
||||
{
|
||||
case LOG_EMERG:
|
||||
case LOG_ALERT:
|
||||
case LOG_CRIT:
|
||||
case LOG_ERR:
|
||||
eventType = EVENTLOG_ERROR_TYPE;
|
||||
break;
|
||||
case LOG_WARNING:
|
||||
eventType = EVENTLOG_WARNING_TYPE;
|
||||
break;
|
||||
case LOG_NOTICE:
|
||||
case LOG_INFO:
|
||||
case LOG_DEBUG:
|
||||
eventType = EVENTLOG_INFORMATION_TYPE;
|
||||
break;
|
||||
default:
|
||||
eventType = EVENTLOG_ERROR_TYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* We need to know how long the buffer needs to be.
|
||||
The only legal way I can see of doing this is to
|
||||
do a vfprintf to /dev/null, and count the bytes
|
||||
output, then do it again to a malloc'ed string. This
|
||||
is ugly, slow, but prevents core dumps :-).
|
||||
*/
|
||||
pass_handler pass;
|
||||
for (int pass_number = 0; pass_number < 2; ++pass_number)
|
||||
{
|
||||
int n = pass.initialize (pass_number);
|
||||
if (n == -1)
|
||||
return;
|
||||
else if (n > 0)
|
||||
pass.set_message ((char *) alloca (n));
|
||||
|
||||
/* Deal with ident_string */
|
||||
if (_my_tls.locals.process_ident != NULL)
|
||||
{
|
||||
if (pass.print ("%s: ", _my_tls.locals.process_ident) == -1)
|
||||
return;
|
||||
}
|
||||
if (_my_tls.locals.process_logopt & LOG_PID)
|
||||
{
|
||||
if (pass.print ("PID %u: ", getpid ()) == -1)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!wincap.has_eventlog ())
|
||||
{
|
||||
/* Add a priority string - not needed for systems with
|
||||
eventlog capability. */
|
||||
switch (LOG_PRI (priority))
|
||||
{
|
||||
case LOG_EMERG:
|
||||
pass.print ("%s: ", "LOG_EMERG");
|
||||
break;
|
||||
case LOG_ALERT:
|
||||
pass.print ("%s: ", "LOG_ALERT");
|
||||
break;
|
||||
case LOG_CRIT:
|
||||
pass.print ("%s: ", "LOG_CRIT");
|
||||
break;
|
||||
case LOG_ERR:
|
||||
pass.print ("%s: ", "LOG_ERR");
|
||||
break;
|
||||
case LOG_WARNING:
|
||||
pass.print ("%s: ", "LOG_WARNING");
|
||||
break;
|
||||
case LOG_NOTICE:
|
||||
pass.print ("%s: ", "LOG_NOTICE");
|
||||
break;
|
||||
case LOG_INFO:
|
||||
pass.print ("%s: ", "LOG_INFO");
|
||||
break;
|
||||
case LOG_DEBUG:
|
||||
pass.print ("%s: ", "LOG_DEBUG");
|
||||
break;
|
||||
default:
|
||||
pass.print ("%s: ", "LOG_ERR");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Print out the variable part */
|
||||
if (pass.print_va (message, ap) == -1)
|
||||
return;
|
||||
|
||||
}
|
||||
const char *msg_strings[1];
|
||||
char *total_msg = pass.get_message ();
|
||||
int len = strlen (total_msg);
|
||||
if (len != 0 && (total_msg[len - 1] == '\n'))
|
||||
total_msg[--len] = '\0';
|
||||
|
||||
msg_strings[0] = total_msg;
|
||||
|
||||
if (_my_tls.locals.process_logopt & LOG_PERROR)
|
||||
{
|
||||
write (STDERR_FILENO, total_msg, len);
|
||||
write (STDERR_FILENO, "\n", 1);
|
||||
}
|
||||
|
||||
int fd;
|
||||
if ((fd = try_connect_syslogd (priority, total_msg, len + 1)) >= 0)
|
||||
;
|
||||
else if (wincap.has_eventlog ())
|
||||
{
|
||||
/* For NT, open the event log and send the message */
|
||||
HANDLE hEventSrc = RegisterEventSourceA (NULL, (_my_tls.locals.process_ident != NULL) ?
|
||||
_my_tls.locals.process_ident : CYGWIN_LOG_NAME);
|
||||
if (hEventSrc == NULL)
|
||||
{
|
||||
debug_printf ("RegisterEventSourceA failed with %E");
|
||||
return;
|
||||
}
|
||||
if (!ReportEventA (hEventSrc, eventType, 0, 0,
|
||||
cygheap->user.sid (), 1, 0, msg_strings, NULL))
|
||||
debug_printf ("ReportEventA failed with %E");
|
||||
DeregisterEventSource (hEventSrc);
|
||||
cp2++;
|
||||
strcpy (dst, errtext);
|
||||
while (*dst)
|
||||
dst++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Under Windows 95, append the message to the log file */
|
||||
char timestamp[24];
|
||||
time_t ctime;
|
||||
FILE *fp = fopen (get_win95_event_log_path (), "a");
|
||||
if (fp == NULL)
|
||||
{
|
||||
debug_printf ("failed to open file %s",
|
||||
get_win95_event_log_path ());
|
||||
return;
|
||||
}
|
||||
strftime (timestamp, sizeof timestamp, "%Y-%m-%d %H:%M:%S : ",
|
||||
localtime (&(ctime = time (NULL))));
|
||||
*dst++ = *cp2;
|
||||
|
||||
/* Now to prevent several syslog messages from being
|
||||
interleaved, we must lock the first byte of the file
|
||||
This works on Win32 even if we created the file above.
|
||||
*/
|
||||
HANDLE fHandle = cygheap->fdtab[fileno (fp)]->get_handle ();
|
||||
for (int i = 0;; i++)
|
||||
if (LockFile (fHandle, 0, 0, 1, 0) == FALSE)
|
||||
if (i == 3)
|
||||
{
|
||||
debug_printf ("failed to lock file %s", get_win95_event_log_path ());
|
||||
fclose (fp);
|
||||
return;
|
||||
}
|
||||
else
|
||||
usleep (1000);
|
||||
else
|
||||
break;
|
||||
fputs (timestamp, fp);
|
||||
fputs (msg_strings[0], fp);
|
||||
fputc ('\n', fp);
|
||||
fclose (fp);
|
||||
}
|
||||
*dst = '\0';
|
||||
message = newmessage;
|
||||
|
||||
/* Work out the priority type - we ignore the facility for now.. */
|
||||
WORD eventType;
|
||||
switch (LOG_PRI (priority))
|
||||
{
|
||||
case LOG_EMERG:
|
||||
case LOG_ALERT:
|
||||
case LOG_CRIT:
|
||||
case LOG_ERR:
|
||||
eventType = EVENTLOG_ERROR_TYPE;
|
||||
break;
|
||||
case LOG_WARNING:
|
||||
eventType = EVENTLOG_WARNING_TYPE;
|
||||
break;
|
||||
case LOG_NOTICE:
|
||||
case LOG_INFO:
|
||||
case LOG_DEBUG:
|
||||
eventType = EVENTLOG_INFORMATION_TYPE;
|
||||
break;
|
||||
default:
|
||||
eventType = EVENTLOG_ERROR_TYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* We need to know how long the buffer needs to be.
|
||||
The only legal way I can see of doing this is to
|
||||
do a vfprintf to /dev/null, and count the bytes
|
||||
output, then do it again to a malloc'ed string. This
|
||||
is ugly, slow, but prevents core dumps :-).
|
||||
*/
|
||||
pass_handler pass;
|
||||
for (int pass_number = 0; pass_number < 2; ++pass_number)
|
||||
{
|
||||
int n = pass.initialize (pass_number);
|
||||
if (n == -1)
|
||||
return;
|
||||
else if (n > 0)
|
||||
pass.set_message ((char *) alloca (n));
|
||||
|
||||
/* Deal with ident_string */
|
||||
if (_my_tls.locals.process_ident != NULL)
|
||||
{
|
||||
if (pass.print ("%s: ", _my_tls.locals.process_ident) == -1)
|
||||
return;
|
||||
}
|
||||
if (_my_tls.locals.process_logopt & LOG_PID)
|
||||
{
|
||||
if (pass.print ("PID %u: ", getpid ()) == -1)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Print out the variable part */
|
||||
if (pass.print_va (message, ap) == -1)
|
||||
return;
|
||||
|
||||
}
|
||||
const char *msg_strings[1];
|
||||
char *total_msg = pass.get_message ();
|
||||
int len = strlen (total_msg);
|
||||
if (len != 0 && (total_msg[len - 1] == '\n'))
|
||||
total_msg[--len] = '\0';
|
||||
|
||||
msg_strings[0] = total_msg;
|
||||
|
||||
if (_my_tls.locals.process_logopt & LOG_PERROR)
|
||||
{
|
||||
write (STDERR_FILENO, total_msg, len);
|
||||
write (STDERR_FILENO, "\n", 1);
|
||||
}
|
||||
|
||||
int fd;
|
||||
if ((fd = try_connect_syslogd (priority, total_msg, len + 1)) < 0)
|
||||
{
|
||||
/* If syslogd isn't present, open the event log and send the message */
|
||||
HANDLE hEventSrc = RegisterEventSourceA (NULL, (_my_tls.locals.process_ident != NULL) ?
|
||||
_my_tls.locals.process_ident : CYGWIN_LOG_NAME);
|
||||
if (hEventSrc == NULL)
|
||||
{
|
||||
debug_printf ("RegisterEventSourceA failed with %E");
|
||||
return;
|
||||
}
|
||||
if (!ReportEventA (hEventSrc, eventType, 0, 0,
|
||||
cygheap->user.sid (), 1, 0, msg_strings, NULL))
|
||||
debug_printf ("ReportEventA failed with %E");
|
||||
DeregisterEventSource (hEventSrc);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* times.cc
|
||||
|
||||
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
2005 Red Hat, Inc.
|
||||
2005, 2006, 2007 Red Hat, Inc.
|
||||
|
||||
This file is part of Cygwin.
|
||||
|
||||
|
|
|
@ -19,13 +19,7 @@ static NO_COPY wincaps wincap_unknown = {
|
|||
is_server:false,
|
||||
has_security:true,
|
||||
has_security_descriptor_control:false,
|
||||
has_lock_file_ex:true,
|
||||
has_signal_object_and_wait:true,
|
||||
has_eventlog:true,
|
||||
has_ip_helper_lib:false,
|
||||
has_set_handle_information:true,
|
||||
has_set_handle_information_on_console_handles:false,
|
||||
supports_smp:true,
|
||||
map_view_of_file_ex_sucks:false,
|
||||
altgr_is_ctrl_alt:true,
|
||||
has_physical_mem_access:true,
|
||||
|
@ -78,13 +72,7 @@ static NO_COPY wincaps wincap_nt4 = {
|
|||
is_server:false,
|
||||
has_security:true,
|
||||
has_security_descriptor_control:false,
|
||||
has_lock_file_ex:true,
|
||||
has_signal_object_and_wait:true,
|
||||
has_eventlog:true,
|
||||
has_ip_helper_lib:false,
|
||||
has_set_handle_information:true,
|
||||
has_set_handle_information_on_console_handles:false,
|
||||
supports_smp:true,
|
||||
map_view_of_file_ex_sucks:false,
|
||||
altgr_is_ctrl_alt:true,
|
||||
has_physical_mem_access:true,
|
||||
|
@ -137,13 +125,7 @@ static NO_COPY wincaps wincap_nt4sp4 = {
|
|||
is_server:false,
|
||||
has_security:true,
|
||||
has_security_descriptor_control:false,
|
||||
has_lock_file_ex:true,
|
||||
has_signal_object_and_wait:true,
|
||||
has_eventlog:true,
|
||||
has_ip_helper_lib:true,
|
||||
has_set_handle_information:true,
|
||||
has_set_handle_information_on_console_handles:false,
|
||||
supports_smp:true,
|
||||
map_view_of_file_ex_sucks:false,
|
||||
altgr_is_ctrl_alt:true,
|
||||
has_physical_mem_access:true,
|
||||
|
@ -196,13 +178,7 @@ static NO_COPY wincaps wincap_2000 = {
|
|||
is_server:false,
|
||||
has_security:true,
|
||||
has_security_descriptor_control:true,
|
||||
has_lock_file_ex:true,
|
||||
has_signal_object_and_wait:true,
|
||||
has_eventlog:true,
|
||||
has_ip_helper_lib:true,
|
||||
has_set_handle_information:true,
|
||||
has_set_handle_information_on_console_handles:true,
|
||||
supports_smp:true,
|
||||
map_view_of_file_ex_sucks:false,
|
||||
altgr_is_ctrl_alt:true,
|
||||
has_physical_mem_access:true,
|
||||
|
@ -255,13 +231,7 @@ static NO_COPY wincaps wincap_xp = {
|
|||
is_server:false,
|
||||
has_security:true,
|
||||
has_security_descriptor_control:true,
|
||||
has_lock_file_ex:true,
|
||||
has_signal_object_and_wait:true,
|
||||
has_eventlog:true,
|
||||
has_ip_helper_lib:true,
|
||||
has_set_handle_information:true,
|
||||
has_set_handle_information_on_console_handles:true,
|
||||
supports_smp:true,
|
||||
map_view_of_file_ex_sucks:false,
|
||||
altgr_is_ctrl_alt:true,
|
||||
has_physical_mem_access:true,
|
||||
|
@ -314,13 +284,7 @@ static NO_COPY wincaps wincap_2003 = {
|
|||
is_server:true,
|
||||
has_security:true,
|
||||
has_security_descriptor_control:true,
|
||||
has_lock_file_ex:true,
|
||||
has_signal_object_and_wait:true,
|
||||
has_eventlog:true,
|
||||
has_ip_helper_lib:true,
|
||||
has_set_handle_information:true,
|
||||
has_set_handle_information_on_console_handles:true,
|
||||
supports_smp:true,
|
||||
map_view_of_file_ex_sucks:false,
|
||||
altgr_is_ctrl_alt:true,
|
||||
has_physical_mem_access:false,
|
||||
|
@ -373,13 +337,7 @@ static NO_COPY wincaps wincap_vista = {
|
|||
is_server:false,
|
||||
has_security:true,
|
||||
has_security_descriptor_control:true,
|
||||
has_lock_file_ex:true,
|
||||
has_signal_object_and_wait:true,
|
||||
has_eventlog:true,
|
||||
has_ip_helper_lib:true,
|
||||
has_set_handle_information:true,
|
||||
has_set_handle_information_on_console_handles:true,
|
||||
supports_smp:true,
|
||||
map_view_of_file_ex_sucks:false,
|
||||
altgr_is_ctrl_alt:true,
|
||||
has_physical_mem_access:false,
|
||||
|
|
|
@ -19,13 +19,7 @@ struct wincaps
|
|||
unsigned is_server : 1;
|
||||
unsigned has_security : 1;
|
||||
unsigned has_security_descriptor_control : 1;
|
||||
unsigned has_lock_file_ex : 1;
|
||||
unsigned has_signal_object_and_wait : 1;
|
||||
unsigned has_eventlog : 1;
|
||||
unsigned has_ip_helper_lib : 1;
|
||||
unsigned has_set_handle_information : 1;
|
||||
unsigned has_set_handle_information_on_console_handles: 1;
|
||||
unsigned supports_smp : 1;
|
||||
unsigned map_view_of_file_ex_sucks : 1;
|
||||
unsigned altgr_is_ctrl_alt : 1;
|
||||
unsigned has_physical_mem_access : 1;
|
||||
|
@ -94,13 +88,7 @@ public:
|
|||
bool IMPLEMENT (is_server)
|
||||
bool IMPLEMENT (has_security)
|
||||
bool IMPLEMENT (has_security_descriptor_control)
|
||||
bool IMPLEMENT (has_lock_file_ex)
|
||||
bool IMPLEMENT (has_signal_object_and_wait)
|
||||
bool IMPLEMENT (has_eventlog)
|
||||
bool IMPLEMENT (has_ip_helper_lib)
|
||||
bool IMPLEMENT (has_set_handle_information)
|
||||
bool IMPLEMENT (has_set_handle_information_on_console_handles)
|
||||
bool IMPLEMENT (supports_smp)
|
||||
bool IMPLEMENT (map_view_of_file_ex_sucks)
|
||||
bool IMPLEMENT (altgr_is_ctrl_alt)
|
||||
bool IMPLEMENT (has_physical_mem_access)
|
||||
|
|
Loading…
Reference in New Issue