Skip to content

Commit

Permalink
Bring in some freebsd 14 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
laffer1 committed Dec 3, 2024
1 parent 83c57e1 commit f28d6fb
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 43 deletions.
11 changes: 6 additions & 5 deletions bin/mv/mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,12 @@ err: if (unlink(to))
*/
preserve_fd_acls(from_fd, to_fd, from, to);
(void)close(from_fd);

ts[0] = sbp->st_atim;
ts[1] = sbp->st_mtim;
if (futimens(to_fd, ts))
warn("%s: set times", to);

/*
* XXX
* NFS doesn't support chflags; ignore errors unless there's reason
Expand All @@ -351,11 +357,6 @@ err: if (unlink(to))
} else
warn("%s: cannot stat", to);

ts[0] = sbp->st_atim;
ts[1] = sbp->st_mtim;
if (futimens(to_fd, ts))
warn("%s: set times", to);

if (close(to_fd)) {
warn("%s", to);
return (1);
Expand Down
4 changes: 2 additions & 2 deletions bin/setfacl/setfacl.1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd October 26, 2018
.Dd April 29, 2023
.Dt SETFACL 1
.Os
.Sh NAME
Expand Down Expand Up @@ -329,7 +329,7 @@ In entries whose tag type is one of
.Dq Li group@ ,
or
.Dq Li everyone@ ,
this field is omitted altogether, including the trailing comma.
this field is omitted altogether, including the trailing colon.
.It Ar "access permissions"
Access permissions may be specified in either short or long form.
Short and long forms may not be mixed.
Expand Down
30 changes: 20 additions & 10 deletions bin/sleep/sleep.1
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,30 @@
.\"
.\" @(#)sleep.1 8.3 (Berkeley) 4/18/94
.\"
.Dd December 31, 2020
.Dd May 25, 2022
.Dt SLEEP 1
.Os
.Sh NAME
.Nm sleep
.Nd suspend execution for an interval of time
.Sh SYNOPSIS
.Nm
.Ar seconds
.Ar number Ns Op Ar unit
.Ar ...
.Sh DESCRIPTION
The
.Nm
command
suspends execution for a minimum of
.Ar seconds .
command suspends execution for a minimum of
.Ar number
seconds (the default, or unit
.Cm s ) ,
minutes (unit
.Cm m ) ,
hours (unit
.Cm h ) ,
or days (unit
.Cm d ) .
If multiple arguments are passed, the delay will be the sum of all values.
.Pp
If the
.Nm
Expand All @@ -61,11 +70,12 @@ signal is not handled specially by this implementation.
.Pp
The
.Nm
command allows and honors a non-integer number of seconds to sleep
in any form acceptable by
.Xr strtod 3 .
This is a non-portable extension, but is also implemented in GNU sh-utils
since version 2.0a (released in 2002).
command supports other time units than seconds,
honors a non-integer number of time units to sleep in any form acceptable by
.Xr strtod 3 ,
and accepts more than one delay value.
These are non-portable extensions, but they have also been implemented
in GNU sh-utils since version 2.0a (released in 2002).
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
Expand Down
46 changes: 36 additions & 10 deletions bin/sleep/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static char sccsid[] = "@(#)sleep.c 8.3 (Berkeley) 4/2/94";
#include <stdlib.h>
#include <time.h>

static void usage(void);
static void usage(void) __dead2;

static volatile sig_atomic_t report_requested;
static void
Expand All @@ -62,24 +62,48 @@ int
main(int argc, char *argv[])
{
struct timespec time_to_sleep;
double d;
double d, seconds;
time_t original;
char unit;
char buf[2];
int i, matches;

if (caph_limit_stdio() < 0 || caph_enter() < 0)
err(1, "capsicum");

if (argc != 2)
if (argc < 2)
usage();

if (sscanf(argv[1], "%lf%1s", &d, buf) != 1)
usage();
if (d > INT_MAX)
seconds = 0;
for (i = 1; i < argc; i++) {
matches = sscanf(argv[i], "%lf%c%1s", &d, &unit, buf);
if (matches == 2)
switch(unit) {
case 'd':
d *= 24;
/* FALLTHROUGH */
case 'h':
d *= 60;
/* FALLTHROUGH */
case 'm':
d *= 60;
/* FALLTHROUGH */
case 's':
break;
default:
usage();
}
else
if (matches != 1)
usage();
seconds += d;
}
if (seconds > INT_MAX)
usage();
if (d <= 0)
if (seconds <= 0)
return (0);
original = time_to_sleep.tv_sec = (time_t)d;
time_to_sleep.tv_nsec = 1e9 * (d - time_to_sleep.tv_sec);
original = time_to_sleep.tv_sec = (time_t)seconds;
time_to_sleep.tv_nsec = 1e9 * (seconds - time_to_sleep.tv_sec);

signal(SIGINFO, report_request);

Expand All @@ -104,6 +128,8 @@ static void
usage(void)
{

fprintf(stderr, "usage: sleep seconds\n");
fprintf(stderr, "usage: sleep number[unit] ...\n");
fprintf(stderr, "Unit can be 's' (seconds, the default), "
"m (minutes), h (hours), or d (days).\n");
exit(1);
}
2 changes: 1 addition & 1 deletion bin/stty/stty.1
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Assume a line without (with) modem
control.
.It Cm crtscts Pq Fl crtscts
Enable (disable) RTS/CTS flow control.
.It Cm rtsdtr Pq Fl -rtsdtr
.It Cm rtsdtr Pq Fl rtsdtr
Enable (disable) asserting RTS/DTR on open.
.El
.Ss Input Modes:
Expand Down
12 changes: 10 additions & 2 deletions bin/timeout/timeout.1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd October 21, 2021
.Dd June 17, 2024
.Dt TIMEOUT 1
.Os
.Sh NAME
Expand Down Expand Up @@ -192,7 +192,15 @@ $ timeout -k 5s 1m fetch \\
.Ed
.Sh SEE ALSO
.Xr kill 1 ,
.Xr signal 3
.Xr nohup 1 ,
.Xr signal 3 ,
.Xr daemon 8
.Sh STANDARDS
The
.Nm
utility is compliant with the
.St -p1003.1-2024
specification.
.Sh HISTORY
The
.Nm
Expand Down
25 changes: 12 additions & 13 deletions bin/timeout/timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
#include <unistd.h>

#define EXIT_TIMEOUT 124
Expand All @@ -56,7 +55,7 @@ usage(void)
" [--kill-after time | -k time] [--foreground] <duration> <command>"
" <arg ...>\n", getprogname());

exit(EX_USAGE);
exit(EXIT_FAILURE);
}

static double
Expand All @@ -73,7 +72,7 @@ parse_duration(const char *duration)
return (ret);

if (end != NULL && *(end + 1) != '\0')
errx(EX_USAGE, "invalid duration");
errx(125, "invalid duration");

switch (*end) {
case 's':
Expand Down Expand Up @@ -126,7 +125,7 @@ sig_handler(int signo)
return;
}

switch(signo) {
switch (signo) {
case 0:
case SIGINT:
case SIGHUP:
Expand Down Expand Up @@ -154,7 +153,7 @@ set_interval(double iv)
tim.it_value.tv_usec = (suseconds_t)(iv * 1000000UL);

if (setitimer(ITIMER_REAL, &tim, NULL) == -1)
err(EX_OSERR, "setitimer()");
err(EXIT_FAILURE, "setitimer()");
}

int
Expand Down Expand Up @@ -227,7 +226,7 @@ main(int argc, char **argv)
if (!foreground) {
/* Acquire a reaper */
if (procctl(P_PID, getpid(), PROC_REAP_ACQUIRE, NULL) == -1)
err(EX_OSERR, "Fail to acquire the reaper");
err(EXIT_FAILURE, "Fail to acquire the reaper");
}

memset(&signals, 0, sizeof(signals));
Expand All @@ -236,23 +235,23 @@ main(int argc, char **argv)
if (killsig != SIGKILL && killsig != SIGSTOP)
signums[0] = killsig;

for (i = 0; i < sizeof(signums) / sizeof(signums[0]); i ++)
for (i = 0; i < sizeof(signums) / sizeof(signums[0]); i++)
sigaddset(&signals.sa_mask, signums[i]);

signals.sa_handler = sig_handler;
signals.sa_flags = SA_RESTART;

for (i = 0; i < sizeof(signums) / sizeof(signums[0]); i ++)
for (i = 0; i < sizeof(signums) / sizeof(signums[0]); i++)
if (signums[i] != -1 && signums[i] != 0 &&
sigaction(signums[i], &signals, NULL) == -1)
err(EX_OSERR, "sigaction()");
err(EXIT_FAILURE, "sigaction()");

signal(SIGTTIN, SIG_IGN);
signal(SIGTTOU, SIG_IGN);

pid = fork();
if (pid == -1)
err(EX_OSERR, "fork()");
err(EXIT_FAILURE, "fork()");
else if (pid == 0) {
/* child process */
signal(SIGTTIN, SIG_DFL);
Expand All @@ -268,7 +267,7 @@ main(int argc, char **argv)
}

if (sigprocmask(SIG_BLOCK, &signals.sa_mask, NULL) == -1)
err(EX_OSERR, "sigprocmask()");
err(EXIT_FAILURE, "sigprocmask()");

/* parent continues here */
set_interval(first_kill);
Expand Down Expand Up @@ -342,15 +341,15 @@ main(int argc, char **argv)

while (!child_done && wait(&pstat) == -1) {
if (errno != EINTR)
err(EX_OSERR, "waitpid()");
err(EXIT_FAILURE, "waitpid()");
}

if (!foreground)
procctl(P_PID, getpid(), PROC_REAP_RELEASE, NULL);

if (WEXITSTATUS(pstat))
pstat = WEXITSTATUS(pstat);
else if(WIFSIGNALED(pstat))
else if (WIFSIGNALED(pstat))
pstat = 128 + WTERMSIG(pstat);

if (timedout && !preserve)
Expand Down
1 change: 1 addition & 0 deletions bin/uuidgen/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

PACKAGE= runtime
PROG= uuidgen

.include <bsd.prog.mk>
3 changes: 3 additions & 0 deletions bin/uuidgen/Makefile.depend
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
DIRDEPS = \
gnu/lib/csu \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcapsicum \
lib/libcasper/libcasper \
lib/libcompiler_rt \


Expand Down

0 comments on commit f28d6fb

Please sign in to comment.