mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-03 08:11:08 +00:00
Mon Mar 27 02:23:15 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* posix/unistd.h [__USE_BSD] (ttyslot): Declare it. * posix/unistd.h [__USE_BSD] (L_SET, L_INCR, L_XTND): Define unless L_SET already defined. * misc/sys/file.h (L_SET, L_INCR, L_XTND): Don't define if L_SET already defined. Incorporated -lutil library from 4.4-Lite. * misc/Makefile (extra-libs, libutil-routines): New variables. * misc/login.c, misc/login_tty.c, misc/logout.c, misc/logwtmp.c, sysdeps/generic/pty.c: New files for -lutil incorporated from 4.4-Lite. Support simple, light-weight unwind-protect mechanism for longjmp. * setjmp/longjmp.c: Call _longjmp_unwind first thing. * sysdeps/mach/hurd/jmp-unwind.c: New file. * sysdeps/stub/jmp-unwind.c: New file. * sysdeps/i386/jmp_buf.h (_JMPBUF_UNWINDS): New macro. * sysdeps/mips/jmp_buf.h (_JMPBUF_UNWINDS): New macro. * setjmp/Makefile (routines): Add jmp-unwind. * hurd/hurd/userlink.h (struct hurd_userlink): Move `next' and `prevp' members into new substructure `resource'; add another such substructure `thread' and members `cleanup' (function ptr) and `cleanup_data' (generic ptr). (_hurd_userlink_link, _hurd_userlink_unlink): Insert/remove LINK into the `_hurd_self_sigstate ()->active_resources' list via the `thread' substructure. * hurd/hurd/port.h (_hurd_port_cleanup): Declare it. (_hurd_port_locked_get): Set LINK->cleanup to _hurd_port_cleanup and LINK->cleanup_data' to the port extracted. * hurd/hurd/signal.h (struct hurd_sigstate): New member `active_resources'. * hurd/port-cleanup.c: New file. * hurd/Makefile (routines): Add port-cleanup. * malloc/malloc.c: Include errno.h. Sat Mar 25 18:24:21 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu> * locale/loadlocale.c (_nl_load_locale): Avoid */ inside comment.
This commit is contained in:
parent
d365fd2cfa
commit
1474b80f01
42
ChangeLog
42
ChangeLog
@ -1,3 +1,45 @@
|
|||||||
|
Mon Mar 27 02:23:15 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
|
||||||
|
|
||||||
|
* posix/unistd.h [__USE_BSD] (ttyslot): Declare it.
|
||||||
|
|
||||||
|
* posix/unistd.h [__USE_BSD] (L_SET, L_INCR, L_XTND): Define
|
||||||
|
unless L_SET already defined.
|
||||||
|
* misc/sys/file.h (L_SET, L_INCR, L_XTND): Don't define if L_SET
|
||||||
|
already defined.
|
||||||
|
|
||||||
|
Incorporated -lutil library from 4.4-Lite.
|
||||||
|
* misc/Makefile (extra-libs, libutil-routines): New variables.
|
||||||
|
* misc/login.c, misc/login_tty.c, misc/logout.c, misc/logwtmp.c,
|
||||||
|
sysdeps/generic/pty.c: New files for -lutil incorporated from 4.4-Lite.
|
||||||
|
|
||||||
|
Support simple, light-weight unwind-protect mechanism for longjmp.
|
||||||
|
* setjmp/longjmp.c: Call _longjmp_unwind first thing.
|
||||||
|
* sysdeps/mach/hurd/jmp-unwind.c: New file.
|
||||||
|
* sysdeps/stub/jmp-unwind.c: New file.
|
||||||
|
* sysdeps/i386/jmp_buf.h (_JMPBUF_UNWINDS): New macro.
|
||||||
|
* sysdeps/mips/jmp_buf.h (_JMPBUF_UNWINDS): New macro.
|
||||||
|
* setjmp/Makefile (routines): Add jmp-unwind.
|
||||||
|
* hurd/hurd/userlink.h (struct hurd_userlink): Move `next' and
|
||||||
|
`prevp' members into new substructure `resource'; add another such
|
||||||
|
substructure `thread' and members `cleanup' (function ptr) and
|
||||||
|
`cleanup_data' (generic ptr).
|
||||||
|
(_hurd_userlink_link, _hurd_userlink_unlink): Insert/remove LINK
|
||||||
|
into the `_hurd_self_sigstate ()->active_resources' list via the
|
||||||
|
`thread' substructure.
|
||||||
|
* hurd/hurd/port.h (_hurd_port_cleanup): Declare it.
|
||||||
|
(_hurd_port_locked_get): Set LINK->cleanup to _hurd_port_cleanup and
|
||||||
|
LINK->cleanup_data' to the port extracted.
|
||||||
|
* hurd/hurd/signal.h (struct hurd_sigstate): New member
|
||||||
|
`active_resources'.
|
||||||
|
* hurd/port-cleanup.c: New file.
|
||||||
|
* hurd/Makefile (routines): Add port-cleanup.
|
||||||
|
|
||||||
|
* malloc/malloc.c: Include errno.h.
|
||||||
|
|
||||||
|
Sat Mar 25 18:24:21 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
|
||||||
|
|
||||||
|
* locale/loadlocale.c (_nl_load_locale): Avoid */ inside comment.
|
||||||
|
|
||||||
Fri Mar 24 02:35:37 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
|
Fri Mar 24 02:35:37 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
|
||||||
|
|
||||||
* misc/Makefile (headers): Add utmp.h.
|
* misc/Makefile (headers): Add utmp.h.
|
||||||
|
@ -49,7 +49,7 @@ routines = hurdinit hurdid hurdlookup hurdpid hurdrlimit hurdprio hurdexec \
|
|||||||
fopenport \
|
fopenport \
|
||||||
vpprintf \
|
vpprintf \
|
||||||
ports-get ports-set hurdports hurdmsg \
|
ports-get ports-set hurdports hurdmsg \
|
||||||
$(sig) $(dtable) hurdinline
|
$(sig) $(dtable) hurdinline port-cleanup
|
||||||
sig = hurdsig hurdfault faultexc siginfo hurd-raise preempt-sig \
|
sig = hurdsig hurdfault faultexc siginfo hurd-raise preempt-sig \
|
||||||
trampoline longjmp-ts catch-exc exc2signal hurdkill
|
trampoline longjmp-ts catch-exc exc2signal hurdkill
|
||||||
dtable = dtable port2fd new-fd alloc-fd intern-fd \
|
dtable = dtable port2fd new-fd alloc-fd intern-fd \
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Lightweight user references for ports.
|
/* Lightweight user references for ports.
|
||||||
Copyright (C) 1993, 1994 Free Software Foundation, Inc.
|
Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -70,6 +70,9 @@ _hurd_port_init (struct hurd_port *port, mach_port_t init)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Cleanup function for non-local exits. */
|
||||||
|
extern void _hurd_port_cleanup (void *, jmp_buf, int);
|
||||||
|
|
||||||
/* Get a reference to *PORT, which is locked.
|
/* Get a reference to *PORT, which is locked.
|
||||||
Pass return value and LINK to _hurd_port_free when done. */
|
Pass return value and LINK to _hurd_port_free when done. */
|
||||||
|
|
||||||
@ -80,7 +83,11 @@ _hurd_port_locked_get (struct hurd_port *port,
|
|||||||
mach_port_t result;
|
mach_port_t result;
|
||||||
result = port->port;
|
result = port->port;
|
||||||
if (result != MACH_PORT_NULL)
|
if (result != MACH_PORT_NULL)
|
||||||
|
{
|
||||||
|
link->cleanup = &_hurd_port_cleanup;
|
||||||
|
link->cleanup_data = (void *) result;
|
||||||
_hurd_userlink_link (&port->users, link);
|
_hurd_userlink_link (&port->users, link);
|
||||||
|
}
|
||||||
__spin_unlock (&port->lock);
|
__spin_unlock (&port->lock);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,11 @@ struct hurd_sigstate
|
|||||||
will be passed to sigreturn after running the handler for a pending
|
will be passed to sigreturn after running the handler for a pending
|
||||||
signal, instead of examining the thread state. */
|
signal, instead of examining the thread state. */
|
||||||
struct sigcontext *context;
|
struct sigcontext *context;
|
||||||
|
|
||||||
|
/* This is the head of the thread's list of active resources; see
|
||||||
|
<hurd/userlink.h> for details. This member is only used by the
|
||||||
|
thread itself, and always inside a critical section. */
|
||||||
|
struct hurd_userlink *active_resources;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Linked list of states of all threads whose state has been asked for. */
|
/* Linked list of states of all threads whose state has been asked for. */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Support for chains recording users of a resource; `struct hurd_userlink'.
|
/* Support for chains recording users of a resource; `struct hurd_userlink'.
|
||||||
Copyright (C) 1994 Free Software Foundation, Inc.
|
Copyright (C) 1994, 1995 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -25,19 +25,48 @@ Cambridge, MA 02139, USA. */
|
|||||||
#define __need_NULL
|
#define __need_NULL
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include <hurd/signal.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
|
||||||
/* This structure is simply a doubly-linked list. Users of a given
|
|
||||||
resource are recorded by their presence in a list associated with that
|
/* This structure records a link in two doubly-linked lists.
|
||||||
resource. A user attaches his own link (in local storage) to a shared
|
We call these the per-resource user list and the per-thread
|
||||||
chain at the time he begins using some resource. When finished with
|
active-resource list.
|
||||||
that resource, the user removes his link from the chain. If his link is
|
|
||||||
the last (there are no other users of the resource), and his chain has
|
Users of a given resource are recorded by their presence in a list
|
||||||
been detached from the shared cell (the resource in the cell has been
|
associated with that resource. A user attaches his own link (in local
|
||||||
replaced), then the user deallocates the resource that he used. */
|
storage on his stack) to a shared chain at the time he begins using some
|
||||||
|
resource. When finished with that resource, the user removes his link
|
||||||
|
from the chain. If his link is the last (there are no other users of
|
||||||
|
the resource), and his chain has been detached from the shared cell (the
|
||||||
|
resource in the cell has been replaced), then the user deallocates the
|
||||||
|
resource that he used.
|
||||||
|
|
||||||
|
All uses of shared resources by a single thread are linked together by
|
||||||
|
its `active-resource' list; the head of this list is stored in the
|
||||||
|
per-thread sigstate structure. When the thread makes a non-local exit
|
||||||
|
(i.e. longjmp), it will examine its active-resource list, and each link
|
||||||
|
residing in a stack frame being jumped out of will be unlinked from both
|
||||||
|
the resource's user list and the thread's active-resource list, and
|
||||||
|
deallocate the resource if that was the last user link for that resource.
|
||||||
|
|
||||||
|
NOTE: Access to a thread's active-resource list must always be done
|
||||||
|
inside a signal-proof critical section; the functions in this file
|
||||||
|
assume they are called inside a critical section, and do no locking of
|
||||||
|
their own. Also important: the longjmp cleanup relies on all userlink
|
||||||
|
structures residing on the stack of the using thread. */
|
||||||
|
|
||||||
struct hurd_userlink
|
struct hurd_userlink
|
||||||
|
{
|
||||||
|
struct
|
||||||
{
|
{
|
||||||
struct hurd_userlink *next, **prevp;
|
struct hurd_userlink *next, **prevp;
|
||||||
|
} resource, thread;
|
||||||
|
|
||||||
|
/* This function is called when a non-local exit
|
||||||
|
unwinds the frame containing this link. */
|
||||||
|
void (*cleanup) (void *cleanup_data, jmp_buf env, int val);
|
||||||
|
void *cleanup_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -52,32 +81,46 @@ _EXTERN_INLINE void
|
|||||||
_hurd_userlink_link (struct hurd_userlink **chainp,
|
_hurd_userlink_link (struct hurd_userlink **chainp,
|
||||||
struct hurd_userlink *link)
|
struct hurd_userlink *link)
|
||||||
{
|
{
|
||||||
link->next = *chainp;
|
struct hurd_userlink **thread_chainp;
|
||||||
if (link->next)
|
|
||||||
link->next->prevp = &link->next;
|
link->resource.next = *chainp;
|
||||||
link->prevp = chainp;
|
if (link->resource.next)
|
||||||
|
link->resource.next->thread.prevp = &link->resource.next;
|
||||||
|
link->resource.prevp = chainp;
|
||||||
*chainp = link;
|
*chainp = link;
|
||||||
|
|
||||||
|
/* Also chain it on the current thread's list of active resources. */
|
||||||
|
thread_chainp = &_hurd_self_sigstate ()->active_resources;
|
||||||
|
link->thread.next = *thread_chainp;
|
||||||
|
if (link->thread.next)
|
||||||
|
link->thread.next->thread.prevp = &link->thread.next;
|
||||||
|
link->thread.prevp = thread_chainp;
|
||||||
|
*thread_chainp = link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Detach LINK from its chain. If the return value is nonzero, the caller
|
/* Detach LINK from its chain. Returns nonzero iff this was the
|
||||||
should deallocate the resource he started using after attaching LINK to
|
last user of the resource and it should be deallocated. */
|
||||||
the chain it's on. If the return value is zero, then someone else is
|
|
||||||
still using the resource. */
|
|
||||||
|
|
||||||
_EXTERN_INLINE int
|
_EXTERN_INLINE int
|
||||||
_hurd_userlink_unlink (struct hurd_userlink *link)
|
_hurd_userlink_unlink (struct hurd_userlink *link)
|
||||||
{
|
{
|
||||||
/* The caller should deallocate the resource he used if his chain has
|
/* We should deallocate the resource used if this chain has been detached
|
||||||
been detached from the cell (and thus has a nil `prevp'), and there is
|
from the cell (and thus has a nil `prevp'), and there is no next link
|
||||||
no next link representing another user reference to the same resource. */
|
representing another user reference to the same resource. */
|
||||||
int dealloc = ! link->next && ! link->prevp;
|
int dealloc = ! link->resource.next && ! link->resource.prevp;
|
||||||
|
|
||||||
/* Remove our link from the chain of current users. */
|
/* Remove our link from the chain of current users. */
|
||||||
if (link->prevp)
|
if (link->resource.prevp)
|
||||||
*link->prevp = link->next;
|
*link->resource.prevp = link->resource.next;
|
||||||
if (link->next)
|
if (link->resource.next)
|
||||||
link->next->prevp = link->prevp;
|
link->resource.next->resource.prevp = link->resource.prevp;
|
||||||
|
|
||||||
|
/* Remove our link from the chain of currently active resources
|
||||||
|
for this thread. */
|
||||||
|
*link->thread.prevp = link->thread.next;
|
||||||
|
if (link->thread.next)
|
||||||
|
link->thread.next->thread.prevp = link->thread.prevp;
|
||||||
|
|
||||||
return dealloc;
|
return dealloc;
|
||||||
}
|
}
|
||||||
@ -97,7 +140,7 @@ _hurd_userlink_clear (struct hurd_userlink **chainp)
|
|||||||
|
|
||||||
/* Detach the chain of current users from the cell. The last user to
|
/* Detach the chain of current users from the cell. The last user to
|
||||||
remove his link from that chain will deallocate the old resource. */
|
remove his link from that chain will deallocate the old resource. */
|
||||||
(*chainp)->prevp = NULL;
|
(*chainp)->resource.prevp = NULL;
|
||||||
*chainp = NULL;
|
*chainp = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
31
hurd/port-cleanup.c
Normal file
31
hurd/port-cleanup.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/* Cleanup function for `struct hurd_port' users who longjmp.
|
||||||
|
Copyright (C) 1995 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
#include <mach.h>
|
||||||
|
#include <hurd/port.h>
|
||||||
|
|
||||||
|
/* The last user of the send right CLEANUP_DATA is now doing
|
||||||
|
`longjmp (ENV, VAL)', and this will unwind the frame of
|
||||||
|
that last user. Deallocate the right he will never get back to using. */
|
||||||
|
|
||||||
|
void
|
||||||
|
_hurd_port_cleanup (void *cleanup_data, jmp_buf env, int val)
|
||||||
|
{
|
||||||
|
__mach_port_deallocate (__mach_task_self (), (mach_port_t) cleanup_data);
|
||||||
|
}
|
@ -83,7 +83,8 @@ _nl_load_locale (int category, char **name)
|
|||||||
goto puntfd;
|
goto puntfd;
|
||||||
if (S_ISDIR (st.st_mode))
|
if (S_ISDIR (st.st_mode))
|
||||||
{
|
{
|
||||||
/* LOCALE/LC_* is a directory; open LOCALE/LC_*/SYS_LC_* instead. */
|
/* LOCALE/LC_foo is a directory; open LOCALE/LC_foo/SYS_LC_foo
|
||||||
|
instead. */
|
||||||
__close (fd);
|
__close (fd);
|
||||||
memcpy (stpcpy (strchr (file, '\0'), "SYS_"), catname, catlen);
|
memcpy (stpcpy (strchr (file, '\0'), "SYS_"), catname, catlen);
|
||||||
fd = __open (file, O_RDONLY);
|
fd = __open (file, O_RDONLY);
|
||||||
|
@ -56,13 +56,16 @@ extra-objs := bsd-compat.o
|
|||||||
install-lib := libbsd-compat.a libg.a
|
install-lib := libbsd-compat.a libg.a
|
||||||
non-lib.a := libbsd-compat.a
|
non-lib.a := libbsd-compat.a
|
||||||
|
|
||||||
|
# Build the -lutil library with these extra functions.
|
||||||
|
extra-libs := libutil
|
||||||
|
libutil-routines:= login login_tty logout logwtmp pty
|
||||||
|
|
||||||
|
|
||||||
include ../Rules
|
include ../Rules
|
||||||
|
|
||||||
|
|
||||||
$(objpfx)libbsd-compat.a: $(objpfx)bsd-compat.o
|
$(objpfx)libbsd-compat.a: $(objpfx)bsd-compat.o
|
||||||
rm -f $@
|
rm -f $@
|
||||||
ln $< $@
|
ln $< $@
|
||||||
|
|
||||||
lib: $(objpfx)libbsd-compat.a
|
|
||||||
|
|
||||||
$(objpfx)libg.a: $(dep-dummy-lib); $(make-dummy-lib)
|
$(objpfx)libg.a: $(dep-dummy-lib); $(make-dummy-lib)
|
||||||
lib: $(objpfx)libg.a
|
|
||||||
|
63
misc/login.c
Normal file
63
misc/login.c
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1988, 1993
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the University of
|
||||||
|
* California, Berkeley and its contributors.
|
||||||
|
* 4. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
|
static char sccsid[] = "@(#)login.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <utmp.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
login(ut)
|
||||||
|
struct utmp *ut;
|
||||||
|
{
|
||||||
|
register int fd;
|
||||||
|
int tty;
|
||||||
|
|
||||||
|
tty = ttyslot();
|
||||||
|
if (tty > 0 && (fd = open(_PATH_UTMP, O_WRONLY|O_CREAT, 0644)) >= 0) {
|
||||||
|
(void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), L_SET);
|
||||||
|
(void)write(fd, ut, sizeof(struct utmp));
|
||||||
|
(void)close(fd);
|
||||||
|
}
|
||||||
|
if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) {
|
||||||
|
(void)write(fd, ut, sizeof(struct utmp));
|
||||||
|
(void)close(fd);
|
||||||
|
}
|
||||||
|
}
|
55
misc/login_tty.c
Normal file
55
misc/login_tty.c
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 1990, 1993
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the University of
|
||||||
|
* California, Berkeley and its contributors.
|
||||||
|
* 4. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
|
static char sccsid[] = "@(#)login_tty.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
login_tty(fd)
|
||||||
|
int fd;
|
||||||
|
{
|
||||||
|
(void) setsid();
|
||||||
|
if (ioctl(fd, TIOCSCTTY, (char *)NULL) == -1)
|
||||||
|
return (-1);
|
||||||
|
(void) dup2(fd, 0);
|
||||||
|
(void) dup2(fd, 1);
|
||||||
|
(void) dup2(fd, 2);
|
||||||
|
if (fd > 2)
|
||||||
|
(void) close(fd);
|
||||||
|
return (0);
|
||||||
|
}
|
72
misc/logout.c
Normal file
72
misc/logout.c
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1988, 1993
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the University of
|
||||||
|
* California, Berkeley and its contributors.
|
||||||
|
* 4. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
|
static char sccsid[] = "@(#)logout.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <utmp.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
typedef struct utmp UTMP;
|
||||||
|
|
||||||
|
int
|
||||||
|
logout(line)
|
||||||
|
register char *line;
|
||||||
|
{
|
||||||
|
register int fd;
|
||||||
|
UTMP ut;
|
||||||
|
int rval;
|
||||||
|
|
||||||
|
if ((fd = open(_PATH_UTMP, O_RDWR, 0)) < 0)
|
||||||
|
return(0);
|
||||||
|
rval = 0;
|
||||||
|
while (read(fd, &ut, sizeof(UTMP)) == sizeof(UTMP)) {
|
||||||
|
if (!ut.ut_name[0] || strncmp(ut.ut_line, line, UT_LINESIZE))
|
||||||
|
continue;
|
||||||
|
bzero(ut.ut_name, UT_NAMESIZE);
|
||||||
|
bzero(ut.ut_host, UT_HOSTSIZE);
|
||||||
|
(void)time(&ut.ut_time);
|
||||||
|
(void)lseek(fd, -(off_t)sizeof(UTMP), L_INCR);
|
||||||
|
(void)write(fd, &ut, sizeof(UTMP));
|
||||||
|
rval = 1;
|
||||||
|
}
|
||||||
|
(void)close(fd);
|
||||||
|
return(rval);
|
||||||
|
}
|
67
misc/logwtmp.c
Normal file
67
misc/logwtmp.c
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 1988, 1993
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the University of
|
||||||
|
* California, Berkeley and its contributors.
|
||||||
|
* 4. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
|
static char sccsid[] = "@(#)logwtmp.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <utmp.h>
|
||||||
|
|
||||||
|
logwtmp(line, name, host)
|
||||||
|
char *line, *name, *host;
|
||||||
|
{
|
||||||
|
struct utmp ut;
|
||||||
|
struct stat buf;
|
||||||
|
int fd;
|
||||||
|
time_t time();
|
||||||
|
char *strncpy();
|
||||||
|
|
||||||
|
if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0)
|
||||||
|
return;
|
||||||
|
if (fstat(fd, &buf) == 0) {
|
||||||
|
(void) strncpy(ut.ut_line, line, sizeof(ut.ut_line));
|
||||||
|
(void) strncpy(ut.ut_name, name, sizeof(ut.ut_name));
|
||||||
|
(void) strncpy(ut.ut_host, host, sizeof(ut.ut_host));
|
||||||
|
(void) time(&ut.ut_time);
|
||||||
|
if (write(fd, (char *)&ut, sizeof(struct utmp)) !=
|
||||||
|
sizeof(struct utmp))
|
||||||
|
(void) ftruncate(fd, buf.st_size);
|
||||||
|
}
|
||||||
|
(void) close(fd);
|
||||||
|
}
|
@ -30,9 +30,11 @@ __BEGIN_DECLS
|
|||||||
|
|
||||||
/* Alternate names for values for the WHENCE argument to `lseek'.
|
/* Alternate names for values for the WHENCE argument to `lseek'.
|
||||||
These are the same as SEEK_SET, SEEK_CUR, and SEEK_END, respectively. */
|
These are the same as SEEK_SET, SEEK_CUR, and SEEK_END, respectively. */
|
||||||
|
#ifndef L_SET
|
||||||
#define L_SET 0 /* Seek from beginning of file. */
|
#define L_SET 0 /* Seek from beginning of file. */
|
||||||
#define L_INCR 1 /* Seek from current position. */
|
#define L_INCR 1 /* Seek from current position. */
|
||||||
#define L_XTND 2 /* Seek from end of file. */
|
#define L_XTND 2 /* Seek from end of file. */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Operations for the `flock' call. */
|
/* Operations for the `flock' call. */
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
|
"Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
|
||||||
before changing it!
|
before changing it!
|
||||||
|
|
||||||
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94
|
Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of the GNU C Library. Its master source is NOT part of
|
This file is part of the GNU C Library. Its master source is NOT part of
|
||||||
@ -387,7 +387,10 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
|
|||||||
optarg = NULL;
|
optarg = NULL;
|
||||||
|
|
||||||
if (optind == 0)
|
if (optind == 0)
|
||||||
|
{
|
||||||
optstring = _getopt_initialize (optstring);
|
optstring = _getopt_initialize (optstring);
|
||||||
|
optind = 1; /* Don't scan ARGV[0], the program name. */
|
||||||
|
}
|
||||||
|
|
||||||
if (nextchar == NULL || *nextchar == '\0')
|
if (nextchar == NULL || *nextchar == '\0')
|
||||||
{
|
{
|
||||||
|
@ -125,6 +125,14 @@ extern int euidaccess __P ((__const char *__name, int __type));
|
|||||||
#define SEEK_END 2 /* Seek from end of file. */
|
#define SEEK_END 2 /* Seek from end of file. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined (__USE_BSD) && !defined (L_SET)
|
||||||
|
/* Old BSD names for the same constants; just for compatibility. */
|
||||||
|
#define L_SET SEEK_SET
|
||||||
|
#define L_INCR SEEK_CUR
|
||||||
|
#define L_XTND SEEK_END
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Move FD's file position to OFFSET bytes from the
|
/* Move FD's file position to OFFSET bytes from the
|
||||||
beginning of the file (if WHENCE is SEEK_SET),
|
beginning of the file (if WHENCE is SEEK_SET),
|
||||||
the current position (if WHENCE is SEEK_CUR),
|
the current position (if WHENCE is SEEK_CUR),
|
||||||
@ -417,6 +425,12 @@ extern char *ttyname __P ((int __fd));
|
|||||||
extern int __isatty __P ((int __fd));
|
extern int __isatty __P ((int __fd));
|
||||||
extern int isatty __P ((int __fd));
|
extern int isatty __P ((int __fd));
|
||||||
|
|
||||||
|
#ifdef __USE_BSD
|
||||||
|
/* Return the index into the active-logins file (utmp) for
|
||||||
|
the terminal FD is open on. */
|
||||||
|
extern int ttyslot ((int __fd));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Make a link to FROM named TO. */
|
/* Make a link to FROM named TO. */
|
||||||
extern int __link __P ((__const char *__from, __const char *__to));
|
extern int __link __P ((__const char *__from, __const char *__to));
|
||||||
|
@ -24,7 +24,7 @@ subdir := setjmp
|
|||||||
headers := setjmp.h jmp_buf.h
|
headers := setjmp.h jmp_buf.h
|
||||||
|
|
||||||
routines := setjmp sigjmp bsd-setjmp bsd-_setjmp \
|
routines := setjmp sigjmp bsd-setjmp bsd-_setjmp \
|
||||||
longjmp __longjmp
|
longjmp __longjmp jmp-unwind
|
||||||
|
|
||||||
tests := tst-setjmp
|
tests := tst-setjmp
|
||||||
|
|
||||||
|
@ -21,12 +21,17 @@ Cambridge, MA 02139, USA. */
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern void _longjmp_unwind (jmp_buf env, int val);
|
||||||
|
|
||||||
/* Set the signal mask to the one specified in ENV, and jump
|
/* Set the signal mask to the one specified in ENV, and jump
|
||||||
to the position specified in ENV, causing the setjmp
|
to the position specified in ENV, causing the setjmp
|
||||||
call there to return VAL, or 1 if VAL is 0. */
|
call there to return VAL, or 1 if VAL is 0. */
|
||||||
void
|
void
|
||||||
longjmp (sigjmp_buf env, int val)
|
longjmp (sigjmp_buf env, int val)
|
||||||
{
|
{
|
||||||
|
/* Perform any cleanups needed by the frames being unwound. */
|
||||||
|
_longjmp_unwind (env, val);
|
||||||
|
|
||||||
if (env[0].__mask_was_saved)
|
if (env[0].__mask_was_saved)
|
||||||
/* Restore the saved signal mask. */
|
/* Restore the saved signal mask. */
|
||||||
(void) __sigprocmask (SIG_SETMASK, &env[0].__saved_mask,
|
(void) __sigprocmask (SIG_SETMASK, &env[0].__saved_mask,
|
||||||
|
127
sysdeps/generic/pty.c
Normal file
127
sysdeps/generic/pty.c
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
/*-
|
||||||
|
* Copyright (c) 1990, 1993
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the University of
|
||||||
|
* California, Berkeley and its contributors.
|
||||||
|
* 4. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(LIBC_SCCS) && !defined(lint)
|
||||||
|
static char sccsid[] = "@(#)pty.c 8.1 (Berkeley) 6/4/93";
|
||||||
|
#endif /* LIBC_SCCS and not lint */
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <grp.h>
|
||||||
|
|
||||||
|
openpty(amaster, aslave, name, termp, winp)
|
||||||
|
int *amaster, *aslave;
|
||||||
|
char *name;
|
||||||
|
struct termios *termp;
|
||||||
|
struct winsize *winp;
|
||||||
|
{
|
||||||
|
static char line[] = "/dev/ptyXX";
|
||||||
|
register const char *cp1, *cp2;
|
||||||
|
register int master, slave, ttygid;
|
||||||
|
struct group *gr;
|
||||||
|
|
||||||
|
if ((gr = getgrnam("tty")) != NULL)
|
||||||
|
ttygid = gr->gr_gid;
|
||||||
|
else
|
||||||
|
ttygid = -1;
|
||||||
|
|
||||||
|
for (cp1 = "pqrs"; *cp1; cp1++) {
|
||||||
|
line[8] = *cp1;
|
||||||
|
for (cp2 = "0123456789abcdef"; *cp2; cp2++) {
|
||||||
|
line[9] = *cp2;
|
||||||
|
if ((master = open(line, O_RDWR, 0)) == -1) {
|
||||||
|
if (errno == ENOENT)
|
||||||
|
return (-1); /* out of ptys */
|
||||||
|
} else {
|
||||||
|
line[5] = 't';
|
||||||
|
(void) chown(line, getuid(), ttygid);
|
||||||
|
(void) chmod(line, S_IRUSR|S_IWUSR|S_IWGRP);
|
||||||
|
(void) revoke(line);
|
||||||
|
if ((slave = open(line, O_RDWR, 0)) != -1) {
|
||||||
|
*amaster = master;
|
||||||
|
*aslave = slave;
|
||||||
|
if (name)
|
||||||
|
strcpy(name, line);
|
||||||
|
if (termp)
|
||||||
|
(void) tcsetattr(slave,
|
||||||
|
TCSAFLUSH, termp);
|
||||||
|
if (winp)
|
||||||
|
(void) ioctl(slave, TIOCSWINSZ,
|
||||||
|
(char *)winp);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
(void) close(master);
|
||||||
|
line[5] = 'p';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
errno = ENOENT; /* out of ptys */
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
forkpty(amaster, name, termp, winp)
|
||||||
|
int *amaster;
|
||||||
|
char *name;
|
||||||
|
struct termios *termp;
|
||||||
|
struct winsize *winp;
|
||||||
|
{
|
||||||
|
int master, slave, pid;
|
||||||
|
|
||||||
|
if (openpty(&master, &slave, name, termp, winp) == -1)
|
||||||
|
return (-1);
|
||||||
|
switch (pid = fork()) {
|
||||||
|
case -1:
|
||||||
|
return (-1);
|
||||||
|
case 0:
|
||||||
|
/*
|
||||||
|
* child
|
||||||
|
*/
|
||||||
|
(void) close(master);
|
||||||
|
login_tty(slave);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* parent
|
||||||
|
*/
|
||||||
|
*amaster = master;
|
||||||
|
(void) close(slave);
|
||||||
|
return (pid);
|
||||||
|
}
|
@ -7,3 +7,8 @@ typedef struct
|
|||||||
__ptr_t __sp;
|
__ptr_t __sp;
|
||||||
__ptr_t __pc;
|
__ptr_t __pc;
|
||||||
} __jmp_buf[1];
|
} __jmp_buf[1];
|
||||||
|
|
||||||
|
/* Test if longjmp to JMPBUF would unwind the frame
|
||||||
|
containing a local variable at ADDRESS. */
|
||||||
|
#define _JMPBUF_UNWINDS(jmpbuf, address) \
|
||||||
|
((__ptr_t) (address) < (jmpbuf)[0].__sp)
|
||||||
|
62
sysdeps/mach/hurd/jmp-unwind.c
Normal file
62
sysdeps/mach/hurd/jmp-unwind.c
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/* _longjmp_unwind -- Clean up stack frames unwound by longjmp. Hurd version.
|
||||||
|
Copyright (C) 1995 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include <hurd/signal.h>
|
||||||
|
#include <hurd/userlink.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
/* This function is called by `longjmp' (with its arguments) to restore
|
||||||
|
active resources to a sane state before the frames code using them are
|
||||||
|
jumped out of. */
|
||||||
|
|
||||||
|
void
|
||||||
|
_longjmp_unwind (jmp_buf env, int val)
|
||||||
|
{
|
||||||
|
struct hurd_sigstate *ss = _hurd_self_sigstate ();
|
||||||
|
struct hurd_userlink *link;
|
||||||
|
|
||||||
|
/* All access to SS->active_resources must take place inside a critical
|
||||||
|
section where signal handlers cannot run. */
|
||||||
|
__spin_lock (&ss->lock);
|
||||||
|
assert (! ss->critical_section);
|
||||||
|
ss->critical_section = 1;
|
||||||
|
__spin_unlock (&ss->lock);
|
||||||
|
|
||||||
|
#ifndef _JMPBUF_UNWINDS
|
||||||
|
#error "sysdeps/MACHINE/jmp_buf.h fails to define _JMPBUF_UNWINDS"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Iterate over the current thread's list of active resources.
|
||||||
|
Process the head portion of the list whose links reside
|
||||||
|
in stack frames being unwound by this jump. */
|
||||||
|
|
||||||
|
for (link = ss->active_resources;
|
||||||
|
link && _JMPBUF_UNWINDS (env[0].__jmpbuf, link);
|
||||||
|
link = link->thread.next)
|
||||||
|
/* Remove this link from the resource's users list,
|
||||||
|
since the frame using the resource is being unwound.
|
||||||
|
This call returns nonzero if that was the last user. */
|
||||||
|
if (_hurd_userlink_unlink (link))
|
||||||
|
/* One of the frames being unwound by the longjmp was the last user
|
||||||
|
of its resource. Call the cleanup function to deallocate it. */
|
||||||
|
(*link->cleanup) (link->cleanup_data, env, val);
|
||||||
|
|
||||||
|
_hurd_critical_section_unlock (ss);
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/* Define the machine-dependent type `jmp_buf'. Mips version.
|
/* Define the machine-dependent type `jmp_buf'. MIPS version.
|
||||||
Copyright (C) 1992, 1993 Free Software Foundation, Inc.
|
Copyright (C) 1992, 1993, 1995 Free Software Foundation, Inc.
|
||||||
Contributed by Brendan Kehoe (brendan@zen.org).
|
Contributed by Brendan Kehoe (brendan@zen.org).
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -45,3 +45,9 @@ typedef struct
|
|||||||
/* Offset to the program counter in `jmp_buf'. */
|
/* Offset to the program counter in `jmp_buf'. */
|
||||||
#define JB_PC 0
|
#define JB_PC 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Test if longjmp to JMPBUF would unwind the frame
|
||||||
|
containing a local variable at ADDRESS. */
|
||||||
|
#define _JMPBUF_UNWINDS(jmpbuf, address) \
|
||||||
|
((__ptr_t) (address) < (jmpbuf)[0].__sp)
|
||||||
|
29
sysdeps/stub/jmp-unwind.c
Normal file
29
sysdeps/stub/jmp-unwind.c
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/* _longjmp_unwind -- Clean up stack frames unwound by longjmp. Stub version.
|
||||||
|
Copyright (C) 1995 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
||||||
|
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
||||||
|
Cambridge, MA 02139, USA. */
|
||||||
|
|
||||||
|
#include <setjmp.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
_longjmp_unwind (jmp_buf env, int val)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* This function can perform any cleanups necessary to safely unwind the
|
||||||
|
stack frames around the current context which ENV unwinds past. */
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user