Hello community, here is the log from the commit of package recidivm for openSUSE:Factory checked in at 2019-03-18 10:42:07 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/recidivm (Old) and /work/SRC/openSUSE:Factory/.recidivm.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "recidivm" Mon Mar 18 10:42:07 2019 rev:3 rq:685587 version:0.2 Changes: -------- --- /work/SRC/openSUSE:Factory/recidivm/recidivm.changes 2018-03-31 15:38:02.099192183 +0200 +++ /work/SRC/openSUSE:Factory/.recidivm.new.28833/recidivm.changes 2019-03-18 10:42:07.719216548 +0100 @@ -1,0 +2,18 @@ +Sat Mar 16 14:52:34 UTC 2019 - Sebastian Wagner <[email protected]> + +- update to version 0.2 + * Capture stdin by default when stdio is not a tty. + (This should make the -c option redundant for most practical purposes.) + * Error out when target program fails regardless of memory limit. + * Print the help message (-h) on stdout, not stderr. + * Print signal names (e.g. “SIGABRT”) instead of numbers with descriptions + (e.g. “signal 6 (Aborted)”). + * Close unneeded file descriptors. + * Unlink the temporary file as early as possible. + * Improve the build system: + + Set default PREFIX and DESTDIR. + + Add “test-installed” target. + + Add checks against BSD make. + (Only GNU make is supported.) + +------------------------------------------------------------------- Old: ---- recidivm-0.1.4.tar.gz recidivm-0.1.4.tar.gz.asc New: ---- recidivm-0.2.tar.gz recidivm-0.2.tar.gz.asc ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ recidivm.spec ++++++ --- /var/tmp/diff_new_pack.l1yEzp/_old 2019-03-18 10:42:08.351215777 +0100 +++ /var/tmp/diff_new_pack.l1yEzp/_new 2019-03-18 10:42:08.355215771 +0100 @@ -1,7 +1,7 @@ # # spec file for package recidivm # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,12 +12,12 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # Name: recidivm -Version: 0.1.4 +Version: 0.2 Release: 0 Summary: Tool for estimating peak virtual memory use License: MIT ++++++ recidivm-0.1.4.tar.gz -> recidivm-0.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/recidivm-0.1.4/Makefile new/recidivm-0.2/Makefile --- old/recidivm-0.1.4/Makefile 2018-03-12 17:07:54.000000000 +0100 +++ new/recidivm-0.2/Makefile 2019-02-19 19:27:53.000000000 +0100 @@ -1,27 +1,61 @@ +# Copyright © 2015-2019 Jakub Wilk <[email protected]> +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the “Software”), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + CFLAGS ?= -g -O2 CFLAGS += -Wall -Wextra -Wconversion CFLAGS += -D_FILE_OFFSET_BITS=64 +PREFIX = /usr/local +DESTDIR = + +bindir = $(PREFIX)/bin +mandir = $(PREFIX)/share/man + .PHONY: all all: recidivm .PHONY: install install: recidivm - install -d $(DESTDIR)$(PREFIX)/bin - install -m755 $(<) $(DESTDIR)$(PREFIX)/bin/$(<) -ifeq "$(wildcard .git doc/recidivm.1)" ".git" + install -d $(DESTDIR)$(bindir) + install -m755 $(<) $(DESTDIR)$(bindir)/ +ifeq "$(wildcard doc/recidivm.1)" "" # run "$(MAKE) -C doc" to build the manpage else - install -d $(DESTDIR)$(PREFIX)/share/man/man1 - install -m644 doc/recidivm.1 $(DESTDIR)$(PREFIX)/share/man/man1/recidivm.1 + install -d $(DESTDIR)$(mandir)/man1 + install -m644 doc/$(<).1 $(DESTDIR)$(mandir)/man1/ endif .PHONY: test +test: prog=./recidivm test: recidivm - ./recidivm -v -- true + $(prog) -- false; [ $$? -eq 1 ] + $(prog) -v -- true + +.PHONY: test-installed +test-installed: $(or $(shell command -v recidivm;),$(bindir)/recidivm) + $(MAKE) test prog=recidivm .PHONY: clean clean: rm -f recidivm +.error = GNU make is required + # vim:ts=4 sts=4 sw=4 noet diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/recidivm-0.1.4/doc/LICENSE new/recidivm-0.2/doc/LICENSE --- old/recidivm-0.1.4/doc/LICENSE 2018-03-12 17:07:54.000000000 +0100 +++ new/recidivm-0.2/doc/LICENSE 2019-02-19 19:27:53.000000000 +0100 @@ -1,4 +1,4 @@ -Copyright © 2015-2017 Jakub Wilk <[email protected]> +Copyright © 2015-2019 Jakub Wilk <[email protected]> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/recidivm-0.1.4/doc/Makefile new/recidivm-0.2/doc/Makefile --- old/recidivm-0.1.4/doc/Makefile 2018-03-12 17:07:54.000000000 +0100 +++ new/recidivm-0.2/doc/Makefile 2019-02-19 19:27:53.000000000 +0100 @@ -1,16 +1,49 @@ -version = $(shell head -n1 changelog | cut -d ' ' -f2 | tr -d '()') +# Copyright © 2015-2018 Jakub Wilk <[email protected]> +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the “Software”), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +version = $(shell IFS='()' read _ v _ < changelog && echo $$v) .PHONY: all all: recidivm.1 recidivm.1: manpage.pod - sed -e 's/L<\([a-z_-]\+\)(\([0-9]\+\))>/B<\1>(\2)/' $(<) \ + perl -p -e 's/L<([a-z_-]+)[(]([0-9]+)[)]>/B<\1>(\2)/g' $(<) \ | pod2man --utf8 -c '' -n RECIDIVM -r 'recidivm $(version)' \ > $(@).tmp mv $(@).tmp $(@) +.PHONY: check +check: check-pod check-changelog + +.PHONY: check-pod +check-pod: manpage.pod + podchecker -warnings -warnings $(<) + +.PHONY: check-changelog +check-changelog: changelog + dpkg-parsechangelog -l$(<) --all 2>&1 >/dev/null | { ! grep .; } + .PHONY: clean clean: rm -f *.1 *.tmp +.error = GNU make is required + # vim:ts=4 sts=4 sw=4 noet diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/recidivm-0.1.4/doc/changelog new/recidivm-0.2/doc/changelog --- old/recidivm-0.1.4/doc/changelog 2018-03-12 17:07:54.000000000 +0100 +++ new/recidivm-0.2/doc/changelog 2019-02-19 19:27:53.000000000 +0100 @@ -1,3 +1,22 @@ +recidivm (0.2) unstable; urgency=low + + * Capture stdin by default when stdio is not a tty. + (This should make the -c option redundant for most practical purposes.) + * Error out when target program fails regardless of memory limit. + * Print the help message (-h) on stdout, not stderr. + * Print signal names (e.g. “SIGABRT”) instead of numbers with descriptions + (e.g. “signal 6 (Aborted)”). + * Close unneeded file descriptors. + * Unlink the temporary file as early as possible. + * Improve the build system: + + Set default PREFIX and DESTDIR. + + Add “test-installed” target. + + Add checks against BSD make. + (Only GNU make is supported.) + * Improve documentation. + + -- Jakub Wilk <[email protected]> Tue, 19 Feb 2019 19:27:45 +0100 + recidivm (0.1.4) unstable; urgency=low * Fix build failure on OpenBSD. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/recidivm-0.1.4/doc/manpage.pod new/recidivm-0.2/doc/manpage.pod --- old/recidivm-0.1.4/doc/manpage.pod 2018-03-12 17:07:54.000000000 +0100 +++ new/recidivm-0.2/doc/manpage.pod 2019-02-19 19:27:53.000000000 +0100 @@ -39,7 +39,9 @@ Capture stdin and provide fresh copy of it to every instance of the target program. -The default is to redirect stdin to F</dev/null>. +This is the default unless stdin is a terminal. + +If stdin is a terminal, the default is to redirect the target program's stdin to F</dev/null>. =item B<-p> @@ -66,7 +68,7 @@ =item B<-h> -Display help and exit. +Show help message and exit. =back diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/recidivm-0.1.4/doc/recidivm.1 new/recidivm-0.2/doc/recidivm.1 --- old/recidivm-0.1.4/doc/recidivm.1 2018-03-12 17:08:14.000000000 +0100 +++ new/recidivm-0.2/doc/recidivm.1 2019-02-19 19:27:57.000000000 +0100 @@ -1,4 +1,4 @@ -.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) +.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== @@ -54,20 +54,24 @@ .\" Avoid warning from groff about undefined register 'F'. .de IX .. -.if !\nF .nr F 0 -.if \nF>0 \{\ -. de IX -. tm Index:\\$1\t\\n%\t"\\$2" +.nr rF 0 +.if \n(.g .if rF .nr rF 1 +.if (\n(rF:(\n(.g==0)) \{\ +. if \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" .. -. if !\nF==2 \{\ -. nr % 0 -. nr F 2 +. if !\nF==2 \{\ +. nr % 0 +. nr F 2 +. \} . \} .\} +.rr rF .\" ======================================================================== .\" .IX Title "RECIDIVM 1" -.TH RECIDIVM 1 "2018-03-12" "recidivm 0.1.4" "" +.TH RECIDIVM 1 "2019-02-19" "recidivm 0.2" "" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -95,7 +99,9 @@ .IX Item "-c" Capture stdin and provide fresh copy of it to every instance of the target program. .Sp -The default is to redirect stdin to \fI/dev/null\fR. +This is the default unless stdin is a terminal. +.Sp +If stdin is a terminal, the default is to redirect the target program's stdin to \fI/dev/null\fR. .IP "\fB\-p\fR" 4 .IX Item "-p" Don't redirect the target program's stdout or stderr. @@ -116,7 +122,7 @@ Print information about every call to the target program. .IP "\fB\-h\fR" 4 .IX Item "-h" -Display help and exit. +Show help message and exit. .SH "EXAMPLE" .IX Header "EXAMPLE" .Vb 12 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/recidivm-0.1.4/recidivm.c new/recidivm-0.2/recidivm.c --- old/recidivm-0.1.4/recidivm.c 2018-03-12 17:07:54.000000000 +0100 +++ new/recidivm-0.2/recidivm.c 2019-02-19 19:27:53.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright © 2015-2017 Jakub Wilk <[email protected]> +/* Copyright © 2015-2019 Jakub Wilk <[email protected]> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the “Software”), to deal @@ -36,25 +36,25 @@ #define RLIMIT_AS RLIMIT_DATA #endif -void usage(bool explicit) +static void usage(FILE *fp) { - fprintf(stderr, "Usage: recidivm [-cpv] [-u B|K|M] -- <command> [argument...]\n"); - if (!explicit) + fprintf(fp, "Usage: recidivm [-cpv] [-u B|K|M] -- <command> [argument...]\n"); + if (fp == stderr) exit(1); - fprintf(stderr, "\n" + fprintf(fp, "\n" "Options:\n" - " -c capture stdin\n" + " -c capture stdin (default unless stdin is tty)\n" " -p don't redirect stdout and stderr\n" " -u B use byte as unit (default)\n" " -u K use kilobyte as unit\n" " -u M use megabyte as unit\n" " -v be verbose\n" - " -h display this help and exit\n" + " -h show this help message and exit\n" ); exit(0); } -void flush_stdout(void) +static void flush_stdout(void) { int rc; if (ferror(stdout)) { @@ -69,7 +69,7 @@ } } -void fatal_child(const char *func) +static void fatal_child(const char *func) { /* Something went very, very wrong. */ fprintf(stderr, "recidivm: %s: %s\n", func, strerror(errno)); @@ -77,7 +77,7 @@ exit(1); } -int child(char **argv, rlim_t m, int infd, int outfd) +static int child(char **argv, rlim_t m, int infd, int outfd) { struct rlimit limit = {m, m}; int rc = setrlimit(RLIMIT_AS, &limit); @@ -102,7 +102,7 @@ return 1; } -int capture_stdin(void) +static int capture_stdin(void) { const char *tmptemplate = "recidivm.XXXXXX"; const char *tmpdir = getenv("TMPDIR"); @@ -125,6 +125,21 @@ fprintf(stderr, "recidivm: %s: %s\n", tmppath, strerror(errno)); exit(1); } + int rc = unlink(tmppath); + if (rc == -1) { + fprintf(stderr, "recidivm: %s: %s\n", tmppath, strerror(errno)); + exit(1); + } + int flags = fcntl(fd, F_GETFD); + if (flags == -1) { + fprintf(stderr, "recidivm: %s: %s\n", tmppath, strerror(errno)); + exit(1); + } + rc = fcntl(fd, F_SETFD, flags | FD_CLOEXEC); + if (rc == -1) { + fprintf(stderr, "recidivm: %s: %s\n", tmppath, strerror(errno)); + exit(1); + } char buffer[BUFSIZ]; ssize_t i; while ((i = read(STDIN_FILENO, buffer, sizeof buffer))) { @@ -142,16 +157,11 @@ exit(1); } } - int rc = unlink(tmppath); - if (rc == -1) { - fprintf(stderr, "recidivm: %s: %s\n", tmppath, strerror(errno)); - exit(1); - } free(tmppath); return fd; } -rlim_t roundto(rlim_t n, rlim_t unit) +static rlim_t roundto(rlim_t n, rlim_t unit) { assert(n > 0); assert(unit > 0); @@ -163,6 +173,49 @@ return (rlim_t) -1; } +static const char * get_signal_name(int sig) +{ + switch (sig) { +#define s(n) case n: return #n; + /* POSIX.1-1990: */ + s(SIGHUP); + s(SIGINT); + s(SIGQUIT); + s(SIGILL); + s(SIGABRT); + s(SIGFPE); + s(SIGKILL); + s(SIGSEGV); + s(SIGPIPE); + s(SIGALRM); + s(SIGTERM); + s(SIGUSR1); + s(SIGUSR2); + s(SIGCHLD); + s(SIGCONT); + s(SIGSTOP); + s(SIGTSTP); + s(SIGTTIN); + s(SIGTTOU); + /* SUSv2 and POSIX.1-2001: */ + s(SIGBUS); +#ifdef SIGPOLL + /* not supported on OpenBSD */ + s(SIGPOLL); +#endif + s(SIGPROF); + s(SIGSYS); + s(SIGTRAP); + s(SIGURG); + s(SIGVTALRM); + s(SIGXCPU); + s(SIGXFSZ); +#undef s + default: + return NULL; + } +} + int main(int argc, char **argv) { int rc; @@ -185,7 +238,7 @@ break; switch (opt) { case 'h': - usage(true); + usage(stdout); break; case 'c': opt_capture_stdin = true; @@ -220,20 +273,20 @@ opt_verbose = true; break; case '?': - usage(false); + usage(stderr); break; default: assert("unexpected getopt(3) return value" == NULL); } } if (optind >= argc) - usage(false); - nullfd = open("/dev/null", O_RDWR); + usage(stderr); + nullfd = open("/dev/null", O_RDWR | O_CLOEXEC); if (nullfd == -1) { perror("recidivm: /dev/null"); return 1; } - infd = opt_capture_stdin + infd = (opt_capture_stdin || !isatty(STDIN_FILENO)) ? capture_stdin() : nullfd; if (!opt_print) @@ -267,6 +320,7 @@ assert(r > l); if (opt_unit > step) step = opt_unit; + bool ok = false; while (roundto(l, step) < roundto(r, step)) { rlim_t m; if (sizeof (rlim_t) > 6 && l == 1 && (r >> 30 >> 16)) @@ -306,19 +360,28 @@ fprintf(stderr, "exit status %d", WEXITSTATUS(status)); else if (WIFSIGNALED(status)) { int termsig = WTERMSIG(status); - fprintf(stderr, "signal %d (%s)", termsig, strsignal(termsig)); + const char *signame = get_signal_name(termsig); + if (signame) + fprintf(stderr, "%s", signame); + else + fprintf(stderr, "signal %d (%s)", termsig, strsignal(termsig)); } else assert("unexpected wait(2) status" == NULL); fprintf(stderr, "\n"); } - if (status == 0) + if (status == 0) { r = m; - else + ok = true; + } else l = m + 1; break; } } } + if (!ok) { + fprintf(stderr, "recidivm: target program fails regardless of memory limit\n"); + return 1; + } printf("%ju\n", (uintmax_t) (roundto(l, step) / opt_unit)); flush_stdout(); return 0;
