svn commit: r330561 - head/bin/chflags
Bryan Drewery
bdrewery at FreeBSD.org
Wed Mar 7 01:55:40 UTC 2018
Author: bdrewery
Date: Wed Mar 7 01:55:38 2018
New Revision: 330561
URL: https://svnweb.freebsd.org/changeset/base/330561
Log:
chflags: Add SIGINFO support.
This is copied from chmod r311668.
MFC after: 2 weeks
Modified:
head/bin/chflags/chflags.1
head/bin/chflags/chflags.c
Modified: head/bin/chflags/chflags.1
==============================================================================
--- head/bin/chflags/chflags.1 Tue Mar 6 23:58:53 2018 (r330560)
+++ head/bin/chflags/chflags.1 Wed Mar 7 01:55:38 2018 (r330561)
@@ -32,7 +32,7 @@
.\" @(#)chflags.1 8.4 (Berkeley) 5/2/95
.\" $FreeBSD$
.\"
-.Dd March 4, 2018
+.Dd March 6, 2018
.Dt CHFLAGS 1
.Os
.Sh NAME
@@ -217,6 +217,16 @@ setting.
See
.Xr security 7
for more information on this setting.
+.Pp
+If
+.Nm
+receives a
+.Dv SIGINFO
+signal (see the
+.Cm status
+argument for
+.Xr stty 1 ) ,
+then the current filename as well as the old and new flags are displayed.
.Sh EXIT STATUS
.Ex -std
.Sh SEE ALSO
Modified: head/bin/chflags/chflags.c
==============================================================================
--- head/bin/chflags/chflags.c Tue Mar 6 23:58:53 2018 (r330560)
+++ head/bin/chflags/chflags.c Wed Mar 7 01:55:38 2018 (r330561)
@@ -51,13 +51,23 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <fcntl.h>
#include <fts.h>
+#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+static volatile sig_atomic_t siginfo;
+
static void usage(void);
+static void
+siginfo_handler(int sig __unused)
+{
+
+ siginfo = 1;
+}
+
int
main(int argc, char *argv[])
{
@@ -108,6 +118,8 @@ main(int argc, char *argv[])
if (argc < 2)
usage();
+ (void)signal(SIGINFO, siginfo_handler);
+
if (Rflag) {
if (hflag)
errx(1, "the -R and -h options may not be "
@@ -188,13 +200,14 @@ main(int argc, char *argv[])
atflag) == -1 && !fflag) {
warn("%s", p->fts_path);
rval = 1;
- } else if (vflag) {
+ } else if (vflag || siginfo) {
(void)printf("%s", p->fts_path);
- if (vflag > 1)
+ if (vflag > 1 || siginfo)
(void)printf(": 0%lo -> 0%lo",
(u_long)p->fts_statp->st_flags,
newflags);
(void)printf("\n");
+ siginfo = 0;
}
}
if (errno)
More information about the svn-src-head
mailing list