Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The new doctesting framework doesn't like being run with nohup #14307

Closed
kiwifb opened this issue Mar 19, 2013 · 15 comments
Closed

The new doctesting framework doesn't like being run with nohup #14307

kiwifb opened this issue Mar 19, 2013 · 15 comments

Comments

@kiwifb
Copy link
Member

kiwifb commented Mar 19, 2013

When run inside nohup test are failing to run with the new doctesting framework in 5.9.beta0. An example

fbissey@QCD-nzi3 /home/work/fbissey/sandbox/sage-5.9.beta0 $ ./sage -t --long "devel/sage-main/sage/misc/inline_fortran.py"
Running doctests with ID 2013-03-19-22-26-09-85e3b5eb.
Doctesting 1 file.
sage -t --long devel/sage-main/sage/misc/inline_fortran.py
    [10 tests, 1.1 s]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Total time for all tests: 1.1 seconds
    cpu time: 0.1 seconds
    cumulative wall time: 1.1 seconds

But when the same thing is run with nohup

nohup ./sage -t --long "devel/sage-main/sage/misc/inline_fortran.py" &

The output is

Running doctests with ID 2013-03-19-22-26-21-d52d31ab.
Doctesting 1 file.
sage -t --long devel/sage-main/sage/misc/inline_fortran.py
Process DocTestWorker-1:
Traceback (most recent call last):
  File "/home/work/fbissey/sandbox/sage-5.9.beta0/local/lib/python/multiprocessing/process.py", l
ine 258, in _bootstrap
    self.run()
  File "/home/work/fbissey/sandbox/sage-5.9.beta0/local/lib/python2.7/site-packages/sage/doctest/
forker.py", line 1655, in run
    sys.stdin = os.fdopen(0, "r")
OSError: [Errno 22] Invalid argument
    Bad exit: 1
**********************************************************************
Tests run before process failed:

**********************************************************************
----------------------------------------------------------------------
sage -t --long devel/sage-main/sage/misc/inline_fortran.py  # Bad exit: 1
----------------------------------------------------------------------
Total time for all tests: 0.0 seconds
    cpu time: 0.0 seconds
    cumulative wall time: 0.0 seconds

This is with the following version of nohup

nohup --version
nohup (GNU coreutils) 8.20
Packaged by Gentoo (8.20 (p1.0))
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute 

Depends on #12415

CC: @jdemeyer

Component: doctest framework

Author: Jeroen Demeyer

Reviewer: François Bissey

Merged: sage-5.9.beta1

Issue created by migration from https://trac.sagemath.org/ticket/14307

@kiwifb kiwifb added this to the sage-5.9 milestone Mar 19, 2013
@jdemeyer
Copy link

comment:1

Please add the output of

nohup --version

@jdemeyer
Copy link

comment:2

nohup is crazy. It opens the standard input for writing and claims it's a feature. From nohup sources:

  /* If standard input is a tty, replace it with /dev/null if possible.
     Note that it is deliberately opened for *writing*,
     to ensure any read evokes an error.  */
  if (ignoring_input)
    {
      if (fd_reopen (STDIN_FILENO, "/dev/null", O_WRONLY, 0) < 0)
        {
          error (0, errno, _("failed to render standard input unusable"));
          exit (exit_internal_failure);
        }
      if (!redirecting_stdout && !redirecting_stderr)
        error (0, 0, _("ignoring input"));
    }

@kiwifb

This comment has been minimized.

@kiwifb
Copy link
Member Author

kiwifb commented Mar 19, 2013

comment:3

Updated the summary with nohup version as asked. Sounds crazy all right.

@kiwifb
Copy link
Member Author

kiwifb commented Mar 19, 2013

comment:4

From the info page this is a GNU extension

   If standard input is a terminal, it is redirected from `/dev/null'
so that terminal sessions do not mistakenly consider the terminal to be
used by the command.  This is a GNU extension; programs intended to be
portable to non-GNU hosts should use `nohup COMMAND [ARG]... </dev/null'
instead.

I guess I will try the last bit.

@kiwifb
Copy link
Member Author

kiwifb commented Mar 19, 2013

comment:5

Yes that's a cure

nohup ./sage -t --long "devel/sage-main/sage/misc/inline_fortran.py" </dev/null &

Does work as intended. I guess we can close this as invalid. I have just learnt about a GNU extension that has interesting side effects.

@jdemeyer
Copy link

Attachment: 14307_bad_stdin.patch.gz

@jdemeyer
Copy link

comment:6

It's also good anyway to fix the doctester to handle this case, needs review.

@jdemeyer
Copy link

Dependencies: #12415

@jdemeyer
Copy link

Author: Jeroen Demeyer

@jdemeyer
Copy link

comment:7

nohup essentially does the equivalent of

./sage -t --long "devel/sage-main/sage/misc/inline_fortran.py" 0>/dev/null

which indeed fails without the patch and works with the patch.

@kiwifb
Copy link
Member Author

kiwifb commented Mar 19, 2013

comment:8

ok, will review in the morning in my time zone.

@kiwifb
Copy link
Member Author

kiwifb commented Mar 19, 2013

Reviewer: François Bissey

@kiwifb
Copy link
Member Author

kiwifb commented Mar 19, 2013

comment:9

Works for me now with the patch. Thanks for the fix Jeroen!

@jdemeyer
Copy link

Merged: sage-5.9.beta1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants