Re: svn commit: r268745 - in head/usr.bin: . timeout

2014-07-22 Thread Dag-Erling Smørgrav
Mateusz Guzik mjgu...@gmail.com writes:
 Baptiste Daroussin b...@freebsd.org writes:
  +static sig_atomic_t sig_chld = 0;
  +static sig_atomic_t sig_term = 0;
  +static sig_atomic_t sig_alrm = 0;
  +static sig_atomic_t sig_ign = 0;
 No reason to se these explicitely to 0.

They do however need to be volatile.

DES
-- 
Dag-Erling Smørgrav - d...@des.no
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org

svn commit: r268745 - in head/usr.bin: . timeout

2014-07-16 Thread Baptiste Daroussin
Author: bapt
Date: Wed Jul 16 09:55:36 2014
New Revision: 268745
URL: http://svnweb.freebsd.org/changeset/base/268745

Log:
  New BSDL timeout(1) utility compatible with GNU timeout
  
  it fully passes the GNU timeout regression tests, it is written in a mostly
  portable way (only signal parsing is relying on non portable structures)
  
  Phabric:  D377

Added:
  head/usr.bin/timeout/
  head/usr.bin/timeout/Makefile   (contents, props changed)
  head/usr.bin/timeout/timeout.1   (contents, props changed)
  head/usr.bin/timeout/timeout.c   (contents, props changed)
Modified:
  head/usr.bin/Makefile

Modified: head/usr.bin/Makefile
==
--- head/usr.bin/Makefile   Wed Jul 16 08:59:44 2014(r268744)
+++ head/usr.bin/Makefile   Wed Jul 16 09:55:36 2014(r268745)
@@ -163,6 +163,7 @@ SUBDIR= alias \
${_tests} \
tftp \
time \
+   timeout \
tip \
top \
touch \

Added: head/usr.bin/timeout/Makefile
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.bin/timeout/Makefile   Wed Jul 16 09:55:36 2014
(r268745)
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+PROG=  timeout
+
+.include bsd.prog.mk

Added: head/usr.bin/timeout/timeout.1
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.bin/timeout/timeout.1  Wed Jul 16 09:55:36 2014
(r268745)
@@ -0,0 +1,70 @@
+.\ Copyright (c) 2014 Baptiste Daroussin b...@freebsd.org
+.\ All rights reserved.
+.\
+.\ Redistribution and use in source and binary forms, with or without
+.\ modification, are permitted provided that the following conditions
+.\ are met:
+.\ 1. Redistributions of source code must retain the above copyright
+.\notice, this list of conditions and the following disclaimer.
+.\ 2. Redistributions in binary form must reproduce the above copyright
+.\notice, this list of conditions and the following disclaimer in the
+.\documentation and/or other materials provided with the distribution.
+.\
+.\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\ ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\ SUCH DAMAGE.
+.\
+.\ $FreeBSD$
+.\
+.Dd July 16, 2014
+.Dt TIMEOUT 1
+.Os
+.Sh NAME
+.Nm timeout
+.Nd run a command with a time limit
+.Sh SYNOPSIS
+.Nm
+.Op Fl -signal Ar sig | Fl s Ar sig
+.Op Fl -preserve-status
+.Op Fl -kill-after Ar time | Fl k Ar time
+.Op Fl -foreground
+.Ao Ar duration Ac
+.Ao Ar command Ac
+.Ao Ar args ... Ac
+.Sh DESCRIPTION
+.Nm
+starts the
+.Ar command
+with its
+.Ar args
+and kills if it is still runs after
+.Ar duration .
+.Bl -tag -width -k time, --kill-after time
+.It Fl -preserve-status
+Always exist with the same status as
+.Ar command
+even if it times out.
+.It Fl -foreground
+Do not propagate timeout to the
+.Ar command
+children.
+.It Fl s Ar sig , Fl -signal Ar sig
+Speficy the signal to send on timeout by default
+.Ar SIGTERM .
+.It Fl k Ar time , Fl -kill-after Ar time
+Send a second kill if the
+.Ar command
+is still running after
+.Ar time
+seconds after the first signal was sent
+.Sh SEE ALSO
+.Xr signal 3 ,
+.Xr kill 1

Added: head/usr.bin/timeout/timeout.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.bin/timeout/timeout.c  Wed Jul 16 09:55:36 2014
(r268745)
@@ -0,0 +1,336 @@
+/*-
+ * Copyright (c) 2014 Baptiste Daroussin b...@freebsd.org
+ * Copyright (c) 2014 Vsevolod Stakhov vsevo...@freebsd.org
+ * All rights reserved.
+ *~
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer
+ *in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the 

Re: svn commit: r268745 - in head/usr.bin: . timeout

2014-07-16 Thread Jan Beich
Baptiste Daroussin b...@freebsd.org writes:

 Author: bapt
 Date: Wed Jul 16 09:55:36 2014
 New Revision: 268745
 URL: http://svnweb.freebsd.org/changeset/base/268745

 Log:
   New BSDL timeout(1) utility compatible with GNU timeout
   
   it fully passes the GNU timeout regression tests, it is written in a mostly
   portable way (only signal parsing is relying on non portable structures)

--version is not supported unlike GNU timeout.

 +.It Fl -preserve-status
 +Always exist with the same status as

Exist? What does timeout(1) without the option? The man page lacks
EXIT STATUS section.

  $ timeout 1 sleep 10
  zsh: exit 124

  $ timeout --preserve-status 1 sleep 10
  zsh: exit 143

 + switch (*end) {
 + case 's':
 + break;
 + case 'm':
 + ret *= 60;
 + break;
 + case 'h':
 + ret *= 60 * 60;
 + break;
 + case 'd':
 + ret *= 60 * 60 * 24;
 + break;

These suffixes are not documented.

-

VFEmail.net - http://www.vfemail.net
ONLY AT VFEmail! - Use our Metadata Mitigator to keep your email out of the 
NSA's hands!
$24.95 ONETIME Lifetime accounts with Privacy Features!  
15GB disk! No bandwidth quotas!
Commercial and Bulk Mail Options!  
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r268745 - in head/usr.bin: . timeout

2014-07-16 Thread Mateusz Guzik
On Wed, Jul 16, 2014 at 09:55:36AM +, Baptiste Daroussin wrote:
 Author: bapt
 Date: Wed Jul 16 09:55:36 2014
 New Revision: 268745
 URL: http://svnweb.freebsd.org/changeset/base/268745
 
 Log:
   New BSDL timeout(1) utility compatible with GNU timeout
   
   it fully passes the GNU timeout regression tests, it is written in a mostly
   portable way (only signal parsing is relying on non portable structures)
   
   Phabric:D377
 
 +static sig_atomic_t sig_chld = 0;
 +static sig_atomic_t sig_term = 0;
 +static sig_atomic_t sig_alrm = 0;
 +static sig_atomic_t sig_ign = 0;
 +

No reason to se these explicitely to 0.

 +static void
 +usage(void)
 +{
 + fprintf(stderr, Usage: %s [--signal sig | -s sig] [--preserve-status]
 +  [--kill-after time | -k time] [--foreground] duration command
 +  arg ...\n, getprogname());
 +

Missing newline at the begnning.

 + exit(EX_USAGE);
 +}
 +
 + switch(signo) {
 + case 0:

sig 0? I doubt it is ever delivered.

 + if (timedout  !preserve)
 + pstat = EXIT_TIMEOUT;
 +

Bad indentation.

 + return (pstat);
 +}
 

-- 
Mateusz Guzik mjguzik gmail.com
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r268745 - in head/usr.bin: . timeout

2014-07-16 Thread Baptiste Daroussin
On Wed, Jul 16, 2014 at 12:25:33PM +0200, Jan Beich wrote:
 Baptiste Daroussin b...@freebsd.org writes:
 
  Author: bapt
  Date: Wed Jul 16 09:55:36 2014
  New Revision: 268745
  URL: http://svnweb.freebsd.org/changeset/base/268745
 
  Log:
New BSDL timeout(1) utility compatible with GNU timeout

it fully passes the GNU timeout regression tests, it is written in a 
  mostly
portable way (only signal parsing is relying on non portable structures)
 
 --version is not supported unlike GNU timeout.

True because I found it not accurate in our case.
 
  +.It Fl -preserve-status
  +Always exist with the same status as
 
 Exist? What does timeout(1) without the option? The man page lacks
 EXIT STATUS section.
 
   $ timeout 1 sleep 10
   zsh: exit 124

Yes man page could be improved a bit
 
   $ timeout --preserve-status 1 sleep 10
   zsh: exit 143

signaled program have a exit which is 128 + SIGNAL (this is not documented on
GNU version) yes I should document it
 
  +   switch (*end) {
  +   case 's':
  +   break;
  +   case 'm':
  +   ret *= 60;
  +   break;
  +   case 'h':
  +   ret *= 60 * 60;
  +   break;
  +   case 'd':
  +   ret *= 60 * 60 * 24;
  +   break;
 
 These suffixes are not documented.

True.

regards,
Bapt


pgp1sgZIsxqFK.pgp
Description: PGP signature


Re: svn commit: r268745 - in head/usr.bin: . timeout

2014-07-16 Thread Baptiste Daroussin
On Wed, Jul 16, 2014 at 12:29:08PM +0200, Mateusz Guzik wrote:
 On Wed, Jul 16, 2014 at 09:55:36AM +, Baptiste Daroussin wrote:
  Author: bapt
  Date: Wed Jul 16 09:55:36 2014
  New Revision: 268745
  URL: http://svnweb.freebsd.org/changeset/base/268745
  
  Log:
New BSDL timeout(1) utility compatible with GNU timeout

it fully passes the GNU timeout regression tests, it is written in a 
  mostly
portable way (only signal parsing is relying on non portable structures)

Phabric:  D377
  
  +static sig_atomic_t sig_chld = 0;
  +static sig_atomic_t sig_term = 0;
  +static sig_atomic_t sig_alrm = 0;
  +static sig_atomic_t sig_ign = 0;
  +
 
 No reason to se these explicitely to 0.
 
  +static void
  +usage(void)
  +{
  +   fprintf(stderr, Usage: %s [--signal sig | -s sig] [--preserve-status]
  +[--kill-after time | -k time] [--foreground] duration command
  +arg ...\n, getprogname());
  +
 
 Missing newline at the begnning.
New line at the beginning?
 
  +   exit(EX_USAGE);
  +}
  +
  +   switch(signo) {
  +   case 0:
 
 sig 0? I doubt it is ever delivered.

one of the tests from the GNU testsuite is passing 0 signal
 
  +   if (timedout  !preserve)
  +   pstat = EXIT_TIMEOUT;
  +
 
 Bad indentation.

right I'll fix

regards,
Bapt


pgpePZlnJcGXL.pgp
Description: PGP signature


Re: svn commit: r268745 - in head/usr.bin: . timeout

2014-07-16 Thread Mateusz Guzik
On Wed, Jul 16, 2014 at 12:34:11PM +0200, Baptiste Daroussin wrote:
 On Wed, Jul 16, 2014 at 12:29:08PM +0200, Mateusz Guzik wrote:
  On Wed, Jul 16, 2014 at 09:55:36AM +, Baptiste Daroussin wrote:
   +static void
   +usage(void)
   +{
   + fprintf(stderr, Usage: %s [--signal sig | -s sig] [--preserve-status]
   +  [--kill-after time | -k time] [--foreground] duration command
   +  arg ...\n, getprogname());
   +
  
  Missing newline at the begnning.
 New line at the beginning?
  

static void
usage(void)
{

fprintf(...);

   + exit(EX_USAGE);
   +}
   +
   + switch(signo) {
   + case 0:
  
  sig 0? I doubt it is ever delivered.
 
 one of the tests from the GNU testsuite is passing 0 signal

I even checked. The kernel is not going to deliver signal 0, so checking
for it in signal handler does not seem to make sense.

Does the testcaes fail without it or something?

-- 
Mateusz Guzik mjguzik gmail.com
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org


Re: svn commit: r268745 - in head/usr.bin: . timeout

2014-07-16 Thread Baptiste Daroussin
On Wed, Jul 16, 2014 at 12:45:12PM +0200, Mateusz Guzik wrote:
 On Wed, Jul 16, 2014 at 12:34:11PM +0200, Baptiste Daroussin wrote:
  On Wed, Jul 16, 2014 at 12:29:08PM +0200, Mateusz Guzik wrote:
   On Wed, Jul 16, 2014 at 09:55:36AM +, Baptiste Daroussin wrote:
+static void
+usage(void)
+{
+   fprintf(stderr, Usage: %s [--signal sig | -s sig] 
[--preserve-status]
+[--kill-after time | -k time] [--foreground] duration 
command
+arg ...\n, getprogname());
+
   
   Missing newline at the begnning.
  New line at the beginning?
   
 
 static void
 usage(void)
 {
 
   fprintf(...);

Fixed
 
+   exit(EX_USAGE);
+}
+
+   switch(signo) {
+   case 0:
   
   sig 0? I doubt it is ever delivered.
  
  one of the tests from the GNU testsuite is passing 0 signal
 
 I even checked. The kernel is not going to deliver signal 0, so checking
 for it in signal handler does not seem to make sense.
 
 Does the testcaes fail without it or something?
 

Yes the test fails without it

regards,
Bapt


pgpvbs076Ys0Y.pgp
Description: PGP signature


Re: svn commit: r268745 - in head/usr.bin: . timeout

2014-07-16 Thread Konstantin Belousov
On Wed, Jul 16, 2014 at 09:55:36AM +, Baptiste Daroussin wrote:
 +#include sys/types.h
 +#include sys/time.h
 +#include sys/wait.h
 +#include signal.h
 +#include stdio.h
 +#include stdlib.h
 +#include string.h
 +#include sysexits.h
 +#include unistd.h
 +#include getopt.h
 +#include err.h
 +#include spawn.h
Is this header needed ?
The headers are unordered.

 +#include errno.h
 +#include stdbool.h
 +
 +#define EXIT_TIMEOUT 124
 +
 +static sig_atomic_t sig_chld = 0;
 +static sig_atomic_t sig_term = 0;
 +static sig_atomic_t sig_alrm = 0;
 +static sig_atomic_t sig_ign = 0;
 +
 +static void
 +usage(void)
 +{
There should be empty line after '{' if no local vars are declared.

 + fprintf(stderr, Usage: %s [--signal sig | -s sig] [--preserve-status]
 +  [--kill-after time | -k time] [--foreground] duration command
 +  arg ...\n, getprogname());
 +
 + exit(EX_USAGE);
 +}
 +
 +static double
 +parse_duration(const char *duration)
 +{
 + double ret;
 + char *end;
 +
 + ret = strtod(duration, end);
 + if (ret == 0  end == duration)
 + errx(EXIT_FAILURE, invalid duration);
 +
 + if (end == NULL || *end == '\0')
 + return (ret);
 +
 + if (end != NULL  *(end + 1) != '\0')
 + errx(EX_USAGE, invalid duration);
 +
 + switch (*end) {
 + case 's':
 + break;
 + case 'm':
 + ret *= 60;
 + break;
 + case 'h':
 + ret *= 60 * 60;
 + break;
 + case 'd':
 + ret *= 60 * 60 * 24;
 + break;
 + default:
 + errx(EX_USAGE, invalid duration);
 + }
 + 
 + if (ret  0 || ret = 1UL)
 + errx(EX_USAGE, invalid duration);
 +
 + return (ret);
 +}
 +
 +static int
 +parse_signal(const char *str)
 +{
 + int sig, i;
 + const char *err;
 +
 + sig = strtonum(str, 0, sys_nsig, err);
 +
 + if (err == NULL)
 + return (sig);
 + if (strncasecmp(str, SIG, 3) == 0)
 + str += 3;
 +
 + for (i = 1; i  sys_nsig; i++) {
 + if (strcasecmp(str, sys_signame[i]) == 0)
 + return (i);
 + }
 + 
 + errx(EX_USAGE, invalid signal);
 +}
 +
 +static void
 +sig_handler(int signo)
 +{
 + if (sig_ign != 0  signo == sig_ign) {
 + sig_ign = 0;
 + return;
 + }
 +
 + switch(signo) {
 + case 0:
 + case SIGINT:
 + case SIGHUP:
 + case SIGQUIT:
 + case SIGTERM:
 + sig_term = signo;
 + break;
 + case SIGCHLD:
 + sig_chld = 1;
 + break;
 + case SIGALRM:
 + sig_alrm = 1;
 + break;
 + }
 +}
 +
 +static void
 +set_interval(double iv)
 +{
 + struct itimerval tim;
 +
 + memset(tim, 0, sizeof(tim));
 + tim.it_value.tv_sec = (time_t)iv;
 + iv -= (time_t)iv;
 + tim.it_value.tv_usec = (suseconds_t)(iv * 100UL);
 +
 + if (setitimer(ITIMER_REAL, tim, NULL) == -1)
 + err(EX_OSERR, setitimer());
 +}
 +
 +int
 +main(int argc, char **argv)
 +{
 + int ch;
 + unsigned long i;
 + int foreground, preserve;
 + int error, pstat, status;
 + int killsig = SIGTERM;
 + int killedwith;
 + pid_t pgid, pid, cpid;
 + double first_kill;
 + double second_kill;
 + bool timedout = false;
 + bool do_second_kill = false;
 + struct sigaction signals;
 + int signums[] = {
 + -1,
 + SIGTERM,
 + SIGINT,
 + SIGHUP,
 + SIGCHLD,
 + SIGALRM,
 + SIGQUIT,
 + };
 +
 + foreground = preserve = 0;
 + second_kill = 0;
 + cpid = -1;
 +
 + struct option longopts[] = {
This should be static const.

 + { preserve-status, no_argument,   preserve,1 },
 + { foreground,  no_argument,   foreground,  1 },
 + { kill-after,  required_argument, NULL,'k'},
 + { signal,  required_argument, NULL,'s'},
 + { help,no_argument,   NULL,'h'},
 + { NULL,  0, NULL, 0 }
 + };
 +
 + while ((ch = getopt_long(argc, argv, +k:s:h, longopts, NULL)) != -1) {
 + switch (ch) {
 + case 'k':
 + do_second_kill = true;
 + second_kill = parse_duration(optarg);
 + break;
 + case 's':
 + killsig = parse_signal(optarg);
 + break;
 + case 0:
 + break;
 + case 'h':
 + default:
 + usage();
 + break;
 + }
 + }
 +
 + argc -= optind;
 + argv += optind;
 +
 + if (argc  2)
 + 

Re: svn commit: r268745 - in head/usr.bin: . timeout

2014-07-16 Thread Konstantin Belousov
On Wed, Jul 16, 2014 at 01:29:14PM +0200, Baptiste Daroussin wrote:
 On Wed, Jul 16, 2014 at 12:45:12PM +0200, Mateusz Guzik wrote:
  On Wed, Jul 16, 2014 at 12:34:11PM +0200, Baptiste Daroussin wrote:
   On Wed, Jul 16, 2014 at 12:29:08PM +0200, Mateusz Guzik wrote:
On Wed, Jul 16, 2014 at 09:55:36AM +, Baptiste Daroussin wrote:
 +static void
 +usage(void)
 +{
 + fprintf(stderr, Usage: %s [--signal sig | -s sig] 
 [--preserve-status]
 +  [--kill-after time | -k time] [--foreground] duration 
 command
 +  arg ...\n, getprogname());
 +

Missing newline at the begnning.
   New line at the beginning?

  
  static void
  usage(void)
  {
  
  fprintf(...);
 
 Fixed
  
 + exit(EX_USAGE);
 +}
 +
 + switch(signo) {
 + case 0:

sig 0? I doubt it is ever delivered.
   
   one of the tests from the GNU testsuite is passing 0 signal
  
  I even checked. The kernel is not going to deliver signal 0, so checking
  for it in signal handler does not seem to make sense.
  
  Does the testcaes fail without it or something?
  
 
 Yes the test fails without it

Which test ? Kernel never delivers signal 0.  There were some bugs in
libthr which caused some signals to be reported as signal 0, they are
supposedly fixed.

The kill(0, pid) is defined as testing for the pid existence, but the
target process is not interrupted.


pgpU_D5OLbTW0.pgp
Description: PGP signature


Re: svn commit: r268745 - in head/usr.bin: . timeout

2014-07-16 Thread Sergey Kandaurov
On Wed, Jul 16, 2014 at 09:55:36AM +, Baptiste Daroussin wrote:
 Author: bapt
 Date: Wed Jul 16 09:55:36 2014
 New Revision: 268745
 URL: http://svnweb.freebsd.org/changeset/base/268745
 
 Log:
   New BSDL timeout(1) utility compatible with GNU timeout

The purpose of this utility is unclear.

[...]
 +.Ar args
 +and kills if it is still runs after
 +.Ar duration .
 +.Bl -tag -width -k time, --kill-after time

mdoc warning: A .Bl directive has no matching .El

 +.It Fl -preserve-status
 +Always exist with the same status as
 +.Ar command
 +even if it times out.
 +.It Fl -foreground
 +Do not propagate timeout to the
 +.Ar command
 +children.
 +.It Fl s Ar sig , Fl -signal Ar sig
 +Speficy the signal to send on timeout by default
 +.Ar SIGTERM .
 +.It Fl k Ar time , Fl -kill-after Ar time
 +Send a second kill if the
 +.Ar command
 +is still running after
 +.Ar time
 +seconds after the first signal was sent
 +.Sh SEE ALSO
 +.Xr signal 3 ,
 +.Xr kill 1
 
 Added: head/usr.bin/timeout/timeout.c
 ==
 --- /dev/null 00:00:00 1970   (empty, because file is newly added)
 +++ head/usr.bin/timeout/timeout.cWed Jul 16 09:55:36 2014
 (r268745)
 @@ -0,0 +1,336 @@
 +/*-
 + * Copyright (c) 2014 Baptiste Daroussin b...@freebsd.org
 + * Copyright (c) 2014 Vsevolod Stakhov vsevo...@freebsd.org
 + * All rights reserved.
 + *~

hah? looks like an editor issue

 + * Redistribution and use in source and binary forms, with or without
 + * modification, are permitted provided that the following conditions
 + * are met:
 + * 1. Redistributions of source code must retain the above copyright
 + *notice, this list of conditions and the following disclaimer
 + *in this position and unchanged.
 + * 2. Redistributions in binary form must reproduce the above copyright
 + *notice, this list of conditions and the following disclaimer in the
 + *documentation and/or other materials provided with the distribution.
 + *~

same here



pgpm2RFoTuERI.pgp
Description: PGP signature


Re: svn commit: r268745 - in head/usr.bin: . timeout

2014-07-16 Thread Sergey Kandaurov
On 16 July 2014 13:55, Baptiste Daroussin b...@freebsd.org wrote:
 Author: bapt
 Date: Wed Jul 16 09:55:36 2014
 New Revision: 268745
 URL: http://svnweb.freebsd.org/changeset/base/268745

 Log:
   New BSDL timeout(1) utility compatible with GNU timeout
[...]
(sorry, missed this in a previous reply)

 Added: head/usr.bin/timeout/timeout.1
 ==
 --- /dev/null   00:00:00 1970   (empty, because file is newly added)
 +++ head/usr.bin/timeout/timeout.1  Wed Jul 16 09:55:36 2014
 (r268745)
 @@ -0,0 +1,70 @@
 +.\ Copyright (c) 2014 Baptiste Daroussin b...@freebsd.org
 +.\ All rights reserved.
 +.\
 +.\ Redistribution and use in source and binary forms, with or without
 +.\ modification, are permitted provided that the following conditions
 +.\ are met:
 +.\ 1. Redistributions of source code must retain the above copyright
 +.\notice, this list of conditions and the following disclaimer.
 +.\ 2. Redistributions in binary form must reproduce the above copyright
 +.\notice, this list of conditions and the following disclaimer in the
 +.\documentation and/or other materials provided with the distribution.
 +.\
 +.\ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 +.\ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 +.\ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
 PURPOSE
 +.\ ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 +.\ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 CONSEQUENTIAL
 +.\ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 +.\ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 +.\ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
 STRICT
 +.\ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 +.\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 +.\ SUCH DAMAGE.
 +.\
 +.\ $FreeBSD$
 +.\
 +.Dd July 16, 2014
 +.Dt TIMEOUT 1
 +.Os
 +.Sh NAME
 +.Nm timeout
 +.Nd run a command with a time limit
 +.Sh SYNOPSIS
 +.Nm
 +.Op Fl -signal Ar sig | Fl s Ar sig
 +.Op Fl -preserve-status
 +.Op Fl -kill-after Ar time | Fl k Ar time
 +.Op Fl -foreground
 +.Ao Ar duration Ac
 +.Ao Ar command Ac
 +.Ao Ar args ... Ac
 +.Sh DESCRIPTION
 +.Nm

please

The
.Nm
utility

 +starts the
 +.Ar command
 +with its
 +.Ar args
 +and kills if it is still runs after

and kills _it_ ?

 +.Ar duration .

in what units?

 +.Bl -tag -width -k time, --kill-after time
 +.It Fl -preserve-status
 +Always exist with the same status as
 +.Ar command
 +even if it times out.
 +.It Fl -foreground
 +Do not propagate timeout to the
 +.Ar command
 +children.
 +.It Fl s Ar sig , Fl -signal Ar sig
 +Speficy the signal to send on timeout by default
 +.Ar SIGTERM .
 +.It Fl k Ar time , Fl -kill-after Ar time
 +Send a second kill if the
 +.Ar command
 +is still running after
 +.Ar time
 +seconds after the first signal was sent
 +.Sh SEE ALSO
 +.Xr signal 3 ,
 +.Xr kill 1

The entries are unsorted.


 Added: head/usr.bin/timeout/timeout.c
 ==
 --- /dev/null   00:00:00 1970   (empty, because file is newly added)
 +++ head/usr.bin/timeout/timeout.c  Wed Jul 16 09:55:36 2014
 (r268745)
 @@ -0,0 +1,336 @@
 +/*-
 + * Copyright (c) 2014 Baptiste Daroussin b...@freebsd.org
 + * Copyright (c) 2014 Vsevolod Stakhov vsevo...@freebsd.org
 + * All rights reserved.
 + *~
 + * Redistribution and use in source and binary forms, with or without
 + * modification, are permitted provided that the following conditions
 + * are met:
 + * 1. Redistributions of source code must retain the above copyright
 + *notice, this list of conditions and the following disclaimer
 + *in this position and unchanged.
 + * 2. Redistributions in binary form must reproduce the above copyright
 + *notice, this list of conditions and the following disclaimer in the
 + *documentation and/or other materials provided with the distribution.
 + *~
 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 + */
 +
 +#include sys/cdefs.h
 +__FBSDID($FreeBSD$);
 +
 +#include sys/types.h
 +#include