Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2000-10-12 08:38:29 +0400
committerChristopher Faylor <me@cgf.cx>2000-10-12 08:38:29 +0400
commitec300c997904f1db79cd5ca49f798ae08a3eedba (patch)
treef0573247cacbf2efd21dd594bf3838c036035d4c
parent8251f53ddda33e780b8043665e638a558e0ef719 (diff)
* errno.cc (seterrno_from_win_error): Fix debugging output.
* fhandler.cc (fhandler_base::fstat): Move to inline method in fhandler.h. (fhandler_base::set_io_handle): Ditto. * fhandler.h (fhandler_base): Make some methods inline. * fhandler_console.cc (fhandler_console::write_normal): Make buffer larger. * sigproc.h (sigframe::sigframe): Actually use set ebp parameter correctly. * spawn.cc (spawn_guts): Set dwProcessId when exec'ing. Just exit immediately after reparenting. * syscalls.cc: Sprinkle sigframe stuff throughout. * wait.cc (wait4): Set signal frame here. * dcrt0.cc (__api_fatal): Don't rely on small_printf to display errors. Always display problems to the console, if possible.
-rw-r--r--winsup/cygwin/ChangeLog21
-rw-r--r--winsup/cygwin/dcrt0.cc19
-rw-r--r--winsup/cygwin/errno.cc2
-rw-r--r--winsup/cygwin/fhandler.cc14
-rw-r--r--winsup/cygwin/fhandler.h4
-rw-r--r--winsup/cygwin/fhandler_console.cc7
-rw-r--r--winsup/cygwin/fork.cc3
-rw-r--r--winsup/cygwin/sigproc.h6
-rw-r--r--winsup/cygwin/spawn.cc3
-rw-r--r--winsup/cygwin/syscalls.cc38
-rw-r--r--winsup/cygwin/wait.cc1
11 files changed, 89 insertions, 29 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 140984e46..6cd667b3b 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,24 @@
+Thu Oct 12 00:25:29 2000 Christopher Faylor <cgf@cygnus.com>
+
+ * errno.cc (seterrno_from_win_error): Fix debugging output.
+ * fhandler.cc (fhandler_base::fstat): Move to inline method in
+ fhandler.h.
+ (fhandler_base::set_io_handle): Ditto.
+ * fhandler.h (fhandler_base): Make some methods inline.
+ * fhandler_console.cc (fhandler_console::write_normal): Make buffer
+ larger.
+ * sigproc.h (sigframe::sigframe): Actually use set ebp parameter
+ correctly.
+ * spawn.cc (spawn_guts): Set dwProcessId when exec'ing. Just exit
+ immediately after reparenting.
+ * syscalls.cc: Sprinkle sigframe stuff throughout.
+ * wait.cc (wait4): Set signal frame here.
+
+Tue Oct 10 19:54:06 2000 Christopher Faylor <cgf@cygnus.com>
+
+ * dcrt0.cc (__api_fatal): Don't rely on small_printf to display errors.
+ Always display problems to the console, if possible.
+
Tue Oct 10 15:21:10 2000 Christopher Faylor <cgf@cygnus.com>
* path.cc (cwdstuff::get): Set EINVAL when length is zero.
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 57d38445e..05f5a8d48 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -1042,6 +1042,7 @@ do_exit (int status)
if (tp->getsid () == myself->sid)
kill (-tp->getpgid (), SIGHUP);
}
+
tty_terminate ();
cleanup_pinfo = TRUE;
}
@@ -1085,7 +1086,21 @@ __api_fatal (const char *fmt, ...)
va_start (ap, fmt);
__small_vsprintf (buf, fmt, ap);
va_end (ap);
- small_printf ("%s\n", buf);
+ strcat (buf, "\n");
+ int len = strlen (buf);
+ DWORD done;
+ (void) WriteFile (GetStdHandle (STD_ERROR_HANDLE), buf, len, &done, 0);
+
+ /* Make sure that the message shows up on the screen, too, since this is
+ a serious error. */
+ if (GetFileType (GetStdHandle (STD_ERROR_HANDLE)) != FILE_TYPE_CHAR)
+ {
+ HANDLE h = CreateFileA ("CONOUT$", GENERIC_READ|GENERIC_WRITE,
+ FILE_SHARE_WRITE | FILE_SHARE_WRITE, &sec_none,
+ OPEN_EXISTING, 0, 0);
+ if (h)
+ (void) WriteFile (h, buf, len, &done, 0);
+ }
/* We are going down without mercy. Make sure we reset
our process_state. */
@@ -1159,7 +1174,6 @@ LoadDLLinitfunc (user32)
while (InterlockedIncrement (&here))
{
InterlockedDecrement (&here);
-small_printf ("Multiple tries to read user32.dll\n");
Sleep (0);
}
@@ -1182,7 +1196,6 @@ LoadDLLinitfunc (advapi32)
while (InterlockedIncrement (&here))
{
InterlockedDecrement (&here);
-small_printf ("Multiple tries to read advapi32.dll\n");
Sleep (0);
}
diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc
index 52e27fab0..6f51f21ca 100644
--- a/winsup/cygwin/errno.cc
+++ b/winsup/cygwin/errno.cc
@@ -130,7 +130,7 @@ geterrno_from_win_error (DWORD code, int deferrno)
void __stdcall
seterrno_from_win_error (const char *file, int line, DWORD code)
{
- syscall_printf ("%s:%d \b", file, line);
+ syscall_printf ("%s:%d errno %d", file, line, code);
set_errno (geterrno_from_win_error (code, EACCES));
return;
}
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 20b2c2a1f..7c1299bf8 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -764,13 +764,6 @@ fhandler_base::lock (int, struct flock *)
return -1;
}
-int
-fhandler_base::fstat (struct stat *buf)
-{
- return stat_dev (get_device (), get_unit (), get_namehash (), buf);
- return 0;
-}
-
extern "C" char * __stdcall
rootdir(char *full_path)
{
@@ -980,13 +973,6 @@ fhandler_base::dump (void)
paranoid_printf ("here");
}
-void
-fhandler_base::set_io_handle (HANDLE x)
-{
- debug_printf ("set handle to %p", x);
- io_handle = x;
-}
-
int
fhandler_base::dup (fhandler_base *child)
{
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index ad17825bc..94615ba83 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -154,7 +154,7 @@ public:
virtual ~fhandler_base ();
/* Non-virtual simple accessor functions. */
- void set_io_handle (HANDLE);
+ void set_io_handle (HANDLE x) { io_handle = x; }
void set_cb (size_t size) { cb = size; }
DWORD get_device () { return status & FH_DEVMASK; }
@@ -250,7 +250,7 @@ public:
}
virtual int open (int flags, mode_t mode = 0);
virtual int close ();
- virtual int fstat (struct stat *buf);
+ virtual int fstat (struct stat *buf) { return stat_dev (get_device (), get_unit (), get_namehash (), buf); }
virtual int ioctl (unsigned int cmd, void *);
virtual char const * ttyname () { return get_name(); }
virtual int read (void *ptr, size_t len);
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index dc76df492..1d05ddcee 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -266,7 +266,6 @@ fhandler_console::set_input_state ()
input_tcsetattr (0, &tc->ti);
}
-
static struct
{
SHORT winTop;
@@ -1076,10 +1075,10 @@ fhandler_console::write_normal (const unsigned char *src,
/* Print all the base ones out */
if (found != src)
{
- char buf[256];
- int len = found - src;
+ char buf[4096];
+ size_t len = found - src;
do {
- int l2 = min (256, len);
+ size_t l2 = min (sizeof (buf), len);
CharToOemBuff ((LPCSTR)src, buf, l2);
if (! WriteFile (get_output_handle (), buf, l2, &done, 0))
{
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index 7f77a5f98..ae4ee890b 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -130,7 +130,8 @@ sync_with_child (PROCESS_INFORMATION &pi, HANDLE subproc_ready,
*/
HANDLE w4[2];
- debug_printf ("waiting for child. reason: %s", s);
+ debug_printf ("waiting for child. reason: %s, hang_child %d", s,
+ hang_child);
w4[1] = pi.hProcess;
w4[0] = subproc_ready;
DWORD rc = WaitForMultipleObjects (2, w4, FALSE, FORK_WAIT_TIMEOUT);
diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h
index b852d278d..aef272227 100644
--- a/winsup/cygwin/sigproc.h
+++ b/winsup/cygwin/sigproc.h
@@ -49,7 +49,7 @@ private:
sigthread *st;
public:
- void set (sigthread &t, DWORD ebp = (DWORD) __builtin_frame_address (0))
+ void set (sigthread &t, DWORD ebp)
{
t.lock->acquire ();
st = &t;
@@ -58,10 +58,10 @@ public:
}
sigframe () {st = NULL;}
- sigframe (sigthread &t, int up = 0)
+ sigframe (sigthread &t, DWORD ebp = (DWORD) __builtin_frame_address (0))
{
if (!t.frame && t.id == GetCurrentThreadId ())
- set (t, up);
+ set (t, ebp);
else
st = NULL;
}
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 8542ecb1e..adf5b1f2f 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -699,6 +699,7 @@ skip_arg_parsing:
// close_all_files ();
proc_terminate ();
hExeced = pi.hProcess;
+ myself->dwProcessId = pi.dwProcessId;
/* Set up child's signal handlers */
/* CGF FIXME - consolidate with signal stuff below */
@@ -880,7 +881,7 @@ skip_arg_parsing:
MALLOC_CHECK;
if (mode == _P_OVERLAY)
- do_exit (res | EXIT_NOCLOSEALL);
+ ExitProcess (res);
}
switch (mode)
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 893dab9e2..65d439284 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -64,6 +64,7 @@ extern "C" int
_unlink (const char *ourname)
{
int res = -1;
+ sigframe thisframe (mainthread);
path_conv win32_name (ourname, PC_SYM_NOFOLLOW | PC_FULL);
@@ -247,6 +248,7 @@ extern "C" int
_write (int fd, const void *ptr, size_t len)
{
int res = -1;
+ sigframe thisframe (mainthread);
if (fdtab.not_open (fd))
{
@@ -380,6 +382,7 @@ _open (const char *unix_path, int flags, ...)
va_list ap;
mode_t mode = 0;
fhandler_base *fh;
+ sigframe thisframe (mainthread);
syscall_printf ("open (%s, %p)", unix_path, flags);
if (!check_null_empty_path_errno(unix_path))
@@ -415,6 +418,7 @@ extern "C" off_t
_lseek (int fd, off_t pos, int dir)
{
off_t res;
+ sigframe thisframe (mainthread);
if (fdtab.not_open (fd))
{
@@ -434,6 +438,7 @@ extern "C" int
_close (int fd)
{
int res;
+ sigframe thisframe (mainthread);
syscall_printf ("close (%d)", fd);
@@ -461,6 +466,7 @@ extern "C" int
isatty (int fd)
{
int res;
+ sigframe thisframe (mainthread);
if (fdtab.not_open (fd))
{
@@ -484,6 +490,7 @@ extern "C" int
_link (const char *a, const char *b)
{
int res = -1;
+ sigframe thisframe (mainthread);
path_conv real_a (a, PC_SYM_NOFOLLOW | PC_FULL);
path_conv real_b (b, PC_SYM_NOFOLLOW | PC_FULL);
@@ -714,18 +721,21 @@ done:
extern "C" int
chown (const char * name, uid_t uid, gid_t gid)
{
+ sigframe thisframe (mainthread);
return chown_worker (name, PC_SYM_FOLLOW, uid, gid);
}
extern "C" int
lchown (const char * name, uid_t uid, gid_t gid)
{
+ sigframe thisframe (mainthread);
return chown_worker (name, PC_SYM_IGNORE, uid, gid);
}
extern "C" int
fchown (int fd, uid_t uid, gid_t gid)
{
+ sigframe thisframe (mainthread);
if (fdtab.not_open (fd))
{
syscall_printf ("-1 = fchown (%d,...)", fd);
@@ -763,6 +773,7 @@ extern "C" int
chmod (const char *path, mode_t mode)
{
int res = -1;
+ sigframe thisframe (mainthread);
path_conv win32_path (path);
@@ -836,6 +847,7 @@ done:
extern "C" int
fchmod (int fd, mode_t mode)
{
+ sigframe thisframe (mainthread);
if (fdtab.not_open (fd))
{
syscall_printf ("-1 = fchmod (%d, 0%o)", fd, mode);
@@ -891,6 +903,7 @@ extern "C" int
_fstat (int fd, struct stat *buf)
{
int r;
+ sigframe thisframe (mainthread);
if (fdtab.not_open (fd))
{
@@ -912,6 +925,7 @@ _fstat (int fd, struct stat *buf)
extern "C" int
fsync (int fd)
{
+ sigframe thisframe (mainthread);
if (fdtab.not_open (fd))
{
syscall_printf ("-1 = fsync (%d)", fd);
@@ -939,6 +953,7 @@ sync ()
int __stdcall
stat_dev (DWORD devn, int unit, unsigned long ino, struct stat *buf)
{
+ sigframe thisframe (mainthread);
switch (devn)
{
case FH_CONOUT:
@@ -1084,6 +1099,7 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
extern "C" int
_stat (const char *name, struct stat *buf)
{
+ sigframe thisframe (mainthread);
return stat_worker ("stat", name, buf, 0);
}
@@ -1091,6 +1107,7 @@ _stat (const char *name, struct stat *buf)
extern "C" int
lstat (const char *name, struct stat *buf)
{
+ sigframe thisframe (mainthread);
return stat_worker ("lstat", name, buf, 1);
}
@@ -1099,6 +1116,7 @@ extern int acl_access (const char *, int);
extern "C" int
access (const char *fn, int flags)
{
+ sigframe thisframe (mainthread);
// flags were incorrectly specified
if (flags & ~(F_OK|R_OK|W_OK|X_OK))
{
@@ -1169,6 +1187,7 @@ done:
extern "C" int
_rename (const char *oldpath, const char *newpath)
{
+ sigframe thisframe (mainthread);
int res = 0;
path_conv real_old (oldpath, PC_SYM_NOFOLLOW);
@@ -1265,6 +1284,7 @@ done:
extern "C" int
system (const char *cmdstring)
{
+ sigframe thisframe (mainthread);
int res;
const char* command[4];
_sig_func_ptr oldint, oldquit;
@@ -1532,6 +1552,7 @@ setmode (int fd, int mode)
extern "C" int
ftruncate (int fd, off_t length)
{
+ sigframe thisframe (mainthread);
int res = -1;
if (fdtab.not_open (fd))
@@ -1570,6 +1591,7 @@ ftruncate (int fd, off_t length)
extern "C" int
truncate (const char *pathname, off_t length)
{
+ sigframe thisframe (mainthread);
int fd;
int res = -1;
@@ -1610,6 +1632,7 @@ get_osfhandle (int fd)
extern "C" int
statfs (const char *fname, struct statfs *sfs)
{
+ sigframe thisframe (mainthread);
if (!sfs)
{
set_errno (EFAULT);
@@ -1650,6 +1673,7 @@ statfs (const char *fname, struct statfs *sfs)
extern "C" int
fstatfs (int fd, struct statfs *sfs)
{
+ sigframe thisframe (mainthread);
if (fdtab.not_open (fd))
{
set_errno (EBADF);
@@ -1663,6 +1687,7 @@ fstatfs (int fd, struct statfs *sfs)
extern "C" int
setpgid (pid_t pid, pid_t pgid)
{
+ sigframe thisframe (mainthread);
int res = -1;
if (pid == 0)
pid = getpid ();
@@ -1702,6 +1727,7 @@ out:
extern "C" pid_t
getpgid (pid_t pid)
{
+ sigframe thisframe (mainthread);
if (pid == 0)
pid = getpid ();
@@ -1717,18 +1743,21 @@ getpgid (pid_t pid)
extern "C" int
setpgrp (void)
{
+ sigframe thisframe (mainthread);
return setpgid (0, 0);
}
extern "C" pid_t
getpgrp (void)
{
+ sigframe thisframe (mainthread);
return getpgid (0);
}
extern "C" char *
ptsname (int fd)
{
+ sigframe thisframe (mainthread);
if (fdtab.not_open (fd))
{
set_errno (EBADF);
@@ -1784,6 +1813,7 @@ extern char *internal_getlogin (_pinfo *pi);
extern "C" int
seteuid (uid_t uid)
{
+ sigframe thisframe (mainthread);
if (os_being_run == winNT)
{
if (uid != (uid_t) -1)
@@ -1849,6 +1879,7 @@ seteuid (uid_t uid)
extern "C" int
setegid (gid_t gid)
{
+ sigframe thisframe (mainthread);
if (os_being_run == winNT)
{
if (gid != (gid_t) -1)
@@ -1871,6 +1902,7 @@ setegid (gid_t gid)
extern "C" int
chroot (const char *newroot)
{
+ sigframe thisframe (mainthread);
int ret = -1;
path_conv path(newroot, PC_SYM_FOLLOW | PC_FULL);
@@ -1907,6 +1939,7 @@ done:
extern "C" int
creat (const char *path, mode_t mode)
{
+ sigframe thisframe (mainthread);
return open (path, O_WRONLY | O_CREAT | O_TRUNC, mode);
}
@@ -1919,6 +1952,7 @@ __assertfail ()
extern "C" int
getw (FILE *fp)
{
+ sigframe thisframe (mainthread);
int w, ret;
ret = fread (&w, sizeof (int), 1, fp);
return ret != 1 ? EOF : w;
@@ -1927,6 +1961,7 @@ getw (FILE *fp)
extern "C" int
putw (int w, FILE *fp)
{
+ sigframe thisframe (mainthread);
int ret;
ret = fwrite (&w, sizeof (int), 1, fp);
if (feof (fp) || ferror (fp))
@@ -1997,6 +2032,7 @@ memccpy (_PTR out, const _PTR in, int c, size_t len)
extern "C" int
nice (int incr)
{
+ sigframe thisframe (mainthread);
DWORD priority[] =
{
IDLE_PRIORITY_CLASS,
@@ -2066,6 +2102,7 @@ ffs (int i)
extern "C" void
login (struct utmp *ut)
{
+ sigframe thisframe (mainthread);
register int fd;
int currtty = ttyslot ();
@@ -2090,6 +2127,7 @@ FIXME (cgf): huh?
extern "C" int
logout (char *line)
{
+ sigframe thisframe (mainthread);
int res = 0;
HANDLE ut_fd;
static const char path_utmp[] = _PATH_UTMP;
diff --git a/winsup/cygwin/wait.cc b/winsup/cygwin/wait.cc
index 4ad5afd03..f442ab593 100644
--- a/winsup/cygwin/wait.cc
+++ b/winsup/cygwin/wait.cc
@@ -50,6 +50,7 @@ wait4 (int intpid, int *status, int options, struct rusage *r)
int rc;
waitq *w;
HANDLE waitfor;
+ sigframe thisframe (mainthread);
sigproc_printf ("here");
if (options & ~(WNOHANG | WUNTRACED))