PR/42568: Pedro F. Giffuni: Better signal handling from OpenBSD, but simplified.
This commit is contained in:
parent
1b91b7e11c
commit
87e82597b6
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.34 2009/10/19 18:41:08 bouyer Exp $ */
|
||||
/* $NetBSD: main.c,v 1.35 2010/01/06 18:12:37 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
@ -63,7 +63,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1986, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.34 2009/10/19 18:41:08 bouyer Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.35 2010/01/06 18:12:37 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -87,7 +87,7 @@ __RCSID("$NetBSD: main.c,v 1.34 2009/10/19 18:41:08 bouyer Exp $");
|
||||
#include "fsutil.h"
|
||||
#include "exitvalues.h"
|
||||
|
||||
int returntosingle = 0;
|
||||
volatilel sigatomic_t returntosingle = 0;
|
||||
|
||||
|
||||
static int argtoi(int, const char *, const char *, int);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: utilities.c,v 1.19 2009/10/19 18:41:08 bouyer Exp $ */
|
||||
/* $NetBSD: utilities.c,v 1.20 2010/01/06 18:12:37 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
@ -58,7 +58,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)utilities.c 8.1 (Berkeley) 6/5/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: utilities.c,v 1.19 2009/10/19 18:41:08 bouyer Exp $");
|
||||
__RCSID("$NetBSD: utilities.c,v 1.20 2010/01/06 18:12:37 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -84,7 +84,7 @@ long diskreads, totalreads; /* Disk cache statistics */
|
||||
|
||||
static void rwerror(const char *, daddr_t);
|
||||
|
||||
extern int returntosingle;
|
||||
extern volatile sigatomic_t returntosingle;
|
||||
|
||||
int
|
||||
ftypeok(struct ext2fs_dinode *dp)
|
||||
@ -156,9 +156,11 @@ bufinit(void)
|
||||
if (bufcnt < MINBUFS)
|
||||
bufcnt = MINBUFS;
|
||||
for (i = 0; i < bufcnt; i++) {
|
||||
bp = malloc(sizeof(struct bufarea));
|
||||
bufp = malloc((unsigned int)sblock.e2fs_bsize);
|
||||
bp = size_t(sizeof(struct bufarea));
|
||||
bufp = malloc((size_t)sblock.e2fs_bsize);
|
||||
if (bp == NULL || bufp == NULL) {
|
||||
free(bp);
|
||||
free(bufp);
|
||||
if (i >= MINBUFS)
|
||||
break;
|
||||
errexit("cannot allocate buffer pool");
|
||||
@ -462,7 +464,7 @@ void
|
||||
catch(int n)
|
||||
{
|
||||
ckfini(0);
|
||||
exit(FSCK_EXIT_SIGNALLED);
|
||||
_exit(FSCK_EXIT_SIGNALLED);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -473,9 +475,14 @@ catch(int n)
|
||||
void
|
||||
catchquit(int n)
|
||||
{
|
||||
printf("returning to single-user after filesystem check\n");
|
||||
static const char msg[] =
|
||||
"returning to single-user after filesystem check\n";
|
||||
int serrno = errno;
|
||||
|
||||
(void)write(STDOUT_FILENO, msg, sizeof(msg) - 1);
|
||||
returntosingle = 1;
|
||||
(void)signal(SIGQUIT, SIG_DFL);
|
||||
errno = serrno;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -485,10 +492,12 @@ catchquit(int n)
|
||||
void
|
||||
voidquit(int n)
|
||||
{
|
||||
int serrno = errno;
|
||||
|
||||
sleep(1);
|
||||
(void)signal(SIGQUIT, SIG_IGN);
|
||||
(void)signal(SIGQUIT, SIG_DFL);
|
||||
errno = serrno;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.73 2008/10/12 20:49:43 wiz Exp $ */
|
||||
/* $NetBSD: main.c,v 1.74 2010/01/06 18:12:37 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1986, 1993\
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: main.c,v 1.73 2008/10/12 20:49:43 wiz Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.74 2010/01/06 18:12:37 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -71,7 +71,7 @@ __RCSID("$NetBSD: main.c,v 1.73 2008/10/12 20:49:43 wiz Exp $");
|
||||
#include "snapshot.h"
|
||||
|
||||
int progress = 0;
|
||||
int returntosingle = 0;
|
||||
volatile sigatomic_t returntosingle = 0;
|
||||
|
||||
static int argtoi(int, const char *, const char *, int);
|
||||
static int checkfilesys(const char *, const char *, int);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: utilities.c,v 1.56 2008/07/31 05:38:04 simonb Exp $ */
|
||||
/* $NetBSD: utilities.c,v 1.57 2010/01/06 18:12:37 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
@ -34,7 +34,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)utilities.c 8.6 (Berkeley) 5/19/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: utilities.c,v 1.56 2008/07/31 05:38:04 simonb Exp $");
|
||||
__RCSID("$NetBSD: utilities.c,v 1.57 2010/01/06 18:12:37 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -65,7 +65,7 @@ long diskreads, totalreads; /* Disk cache statistics */
|
||||
|
||||
static void rwerror(const char *, daddr_t);
|
||||
|
||||
extern int returntosingle;
|
||||
extern volatile sigatomic_t returntosingle;
|
||||
|
||||
int
|
||||
ftypeok(union dinode *dp)
|
||||
@ -508,7 +508,7 @@ catch(int sig)
|
||||
markclean = 0;
|
||||
ckfini();
|
||||
}
|
||||
exit(FSCK_EXIT_SIGNALLED);
|
||||
_exit(FSCK_EXIT_SIGNALLED);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -519,12 +519,14 @@ catch(int sig)
|
||||
void
|
||||
catchquit(int sig)
|
||||
{
|
||||
int errsave = errno;
|
||||
static const char msg[] =
|
||||
"returning to single-user after file system check\n";
|
||||
int serrno = errno;
|
||||
|
||||
printf("returning to single-user after file system check\n");
|
||||
(void)write(STDOUT_FILENO, msg, sizeof(msg) - 1);
|
||||
returntosingle = 1;
|
||||
(void)signal(SIGQUIT, SIG_DFL);
|
||||
errno = errsave;
|
||||
errno = serrno;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -534,12 +536,12 @@ catchquit(int sig)
|
||||
void
|
||||
voidquit(int sig)
|
||||
{
|
||||
int errsave = errno;
|
||||
int serrno = errno;
|
||||
|
||||
sleep(1);
|
||||
(void)signal(SIGQUIT, SIG_IGN);
|
||||
(void)signal(SIGQUIT, SIG_DFL);
|
||||
errno = errsave;
|
||||
errno = serrno;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.40 2008/10/12 20:49:43 wiz Exp $ */
|
||||
/* $NetBSD: main.c,v 1.41 2010/01/06 18:12:37 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
@ -52,7 +52,7 @@
|
||||
#include "fsutil.h"
|
||||
#include "exitvalues.h"
|
||||
|
||||
int returntosingle = 0;
|
||||
volatile sigatomic_t returntosingle = 0;
|
||||
|
||||
static int argtoi(int, const char *, const char *, int);
|
||||
static int checkfilesys(const char *, char *, long, int);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: utilities.c,v 1.27 2008/02/23 21:41:48 christos Exp $ */
|
||||
/* $NetBSD: utilities.c,v 1.28 2010/01/06 18:12:37 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
@ -60,7 +60,7 @@
|
||||
|
||||
long diskreads, totalreads; /* Disk cache statistics */
|
||||
|
||||
extern int returntosingle;
|
||||
extern volatile sigatomic_t returntosingle;
|
||||
extern off_t locked_queue_bytes;
|
||||
|
||||
int
|
||||
@ -246,7 +246,7 @@ void
|
||||
catch(int n)
|
||||
{
|
||||
ckfini(0);
|
||||
exit(FSCK_EXIT_SIGNALLED);
|
||||
_exit(FSCK_EXIT_SIGNALLED);
|
||||
}
|
||||
/*
|
||||
* When preening, allow a single quit to signal
|
||||
@ -256,9 +256,14 @@ catch(int n)
|
||||
void
|
||||
catchquit(int n)
|
||||
{
|
||||
printf("returning to single-user after filesystem check\n");
|
||||
static const char msg[] =
|
||||
"returning to single-user after filesystem check\n";
|
||||
int serrno = errno;
|
||||
|
||||
(void)write(STDOUT_FILENO, msg, sizeof(msg) - 1);
|
||||
returntosingle = 1;
|
||||
(void) signal(SIGQUIT, SIG_DFL);
|
||||
serrno = errno;
|
||||
}
|
||||
/*
|
||||
* Ignore a single quit signal; wait and flush just in case.
|
||||
@ -267,10 +272,12 @@ catchquit(int n)
|
||||
void
|
||||
voidquit(int n)
|
||||
{
|
||||
int serrno = errno;
|
||||
|
||||
sleep(1);
|
||||
(void) signal(SIGQUIT, SIG_IGN);
|
||||
(void) signal(SIGQUIT, SIG_DFL);
|
||||
errno = serrno;
|
||||
}
|
||||
/*
|
||||
* determine whether an inode should be fixed.
|
||||
|
Loading…
Reference in New Issue
Block a user