@@ -28,7 +28,7 @@
.\" @(#)gcore.1 8.2 (Berkeley) 4/18/94
.\" $FreeBSD$
.\"
.Dd July 14, 2010
.Dd July 13, 2016
.Dt GCORE 1
.Os
.Sh NAME
@@ -37,7 +37,6 @@
.Sh SYNOPSIS
.Nm
.Op Fl f
.Op Fl s
.Op Fl c Ar core
.Op Ar executable
.Ar pid
@@ -66,15 +65,6 @@ behavior.
As a result, this flag should only be used when the behavior of the
application and any devices it has mapped is fully understood and any side
effects can be controlled or tolerated.
.It Fl s
Stop the process while gathering the core image, and resume it
when done.
This guarantees that the resulting core dump will
be in a consistent state.
The process is resumed even if it was
already stopped.
The same effect can be achieved manually with
.Xr kill 1 .
.El
.Sh FILES
.Bl -tag -width /var/log/messages -compact
@@ -87,17 +87,14 @@ main(int argc, char *argv[])

pflags = 0;
corefile = NULL;
while ((ch = getopt(argc, argv, "c:fs")) != -1) {
while ((ch = getopt(argc, argv, "c:f")) != -1) {
switch (ch) {
case 'c':
corefile = optarg;
break;
case 'f':
pflags |= PFLAGS_FULL;
break;
case 's':
pflags |= PFLAGS_RESUME;
break;
default:
usage();
break;
@@ -362,21 +362,30 @@ int wait_status;
int
wait_child(pid_t pid)
{
sigset_t nset, oset;
struct child *cp;
sigset_t nset, oset;
pid_t rv = 0;

(void)sigemptyset(&nset);
(void)sigaddset(&nset, SIGCHLD);
(void)sigprocmask(SIG_BLOCK, &nset, &oset);

(void)sigprocmask(SIG_BLOCK, &nset, &oset);
/*
* If we have not already waited on the pid (via sigchild)
* wait on it now. Otherwise, use the wait status stashed
* by sigchild.
*/
cp = findchild(pid, 1);

while (!cp->done)
(void)sigsuspend(&oset);
wait_status = cp->status;
delchild(cp);
if (cp == NULL || !cp->done)
rv = waitpid(pid, &wait_status, 0);
else
wait_status = cp->status;
if (cp != NULL)
delchild(cp);
(void)sigprocmask(SIG_SETMASK, &oset, NULL);
return ((WIFEXITED(wait_status) && WEXITSTATUS(wait_status)) ? -1 : 0);
if (rv == -1 || (WIFEXITED(wait_status) && WEXITSTATUS(wait_status)))
return -1;
else
return 0;
}

/*
@@ -55,7 +55,8 @@ int
main(int argc, char *argv[])
{
ACPI_TABLE_HEADER *rsdt, *sdt;
char c, *progname;
int c;
char *progname;
char *dsdt_input_file, *dsdt_output_file;

dsdt_input_file = dsdt_output_file = NULL;
@@ -26,4 +26,42 @@
#
# $FreeBSD$

# Select timezone
chroot $BSDINSTALL_CHROOT tzsetup

# Switch to target timezone
saved_TZ="$TZ"
TZ="${BSDINSTALL_CHROOT}/etc/localtime"
export TZ

# Set date
exec 3>&1
DATE=$(dialog --backtitle 'FreeBSD Installer' \
--title 'Time & Date' \
--ok-label 'Set Date' \
--cancel-label 'Skip' \
--defaultno \
--date-format '%Y%m%d%H%M.%S' \
--calendar '' 2 40 \
2>&1 1>&3) && date $DATE
exec 3>&-

# Set time
exec 3>&1
TIME=$(dialog --backtitle 'FreeBSD Installer' \
--title 'Time & Date' \
--ok-label 'Set Time' \
--cancel-label 'Skip' \
--defaultno \
--time-format '%H%M.%S' \
--timebox '' 2 40 \
2>&1 1>&3) && date $TIME
exec 3>&-

# Switch back
if [ -n "$saved_TZ" ]; then
TZ="$saved_TZ"
else
unset TZ
fi
unset saved_TZ