diff --git a/bin/chflags/chflags.1 b/bin/chflags/chflags.1 index 6966f6c0fbc4..942cfe9bf137 100644 --- a/bin/chflags/chflags.1 +++ b/bin/chflags/chflags.1 @@ -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 diff --git a/bin/chflags/chflags.c b/bin/chflags/chflags.c index 3121f470e13a..c1d9c18b9b6b 100644 --- a/bin/chflags/chflags.c +++ b/bin/chflags/chflags.c @@ -51,13 +51,23 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include #include +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)