Commit Graph

19 Commits

Author SHA1 Message Date
Matt Harbison
301395709e killdaemons: explicitly set the ctypes signatures
When I tried importing util.posixfile to work around removing a file opened by
another process on Windows, it brought along the declarations in win32.py, which
broke the error handling[1].  It doesn't seem worth hacking killdaemons[2] just
to isolate these declarations in win32.py, so just declare them here to prevent
any future issues.  (win32.py mentions the declarations are required by pypy.)

[1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-May/097905.html
[2] https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-May/097907.html
2017-06-06 20:18:06 -04:00
Matt Harbison
66cdc3e9cb killdaemons: close pid file before killing processes
With #serve enabled on Windows, I was getting occasional stacktraces like this:

  Errored test-hgweb-json.t: Traceback (most recent call last):
    File "./run-tests.py", line 724, in run
      self.tearDown()
    File "./run-tests.py", line 805, in tearDown
      killdaemons(entry)
    File "./run-tests.py", line 540, in killdaemons
      logfn=vlog)
    File "...\tests\killdaemons.py", line 94, in killdaemons
      os.unlink(pidfile)
  WindowsError: [Error 32] The process cannot access the file because it is
     being used by another process: '...\\hgtests.zmpqj3\\child80\\daemon.pids'

Adrian suggested using util.posixfile, which works.  However, the 'mercurial'
package isn't in sys.path when invoking run-tests.py, and it isn't clear that
hacking[1] it in is a good thing (especially for test-run-tests.t, which uses an
installation in a temp folder).

I tried using ProcessMonitor to figure out what the other process is, but that
monitoring slows things down to such a degree that the issue doesn't occur.  I
was ready to blame the virus scanner, but it happens without that too.

Looking at the code, I don't see anything that would have the pid file open.
But I was able to get through about 20 full test runs without an issue with this
minor change, whereas before it was pretty certain to hit this at least once in
two or three runs.

[1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-May/097907.html
2017-05-22 21:45:02 -04:00
Yuya Nishihara
a6fdd0b148 killdaemons: prevent killing all user processes by bad pid file
When I was fixing the test-gpg issue, I noticed gpg-connect-agent could print
"-1" as a server pid if command was wrong. I'm not pretty sure but nobody
would want to kill their running applications by mistake.
2016-08-18 18:43:48 +09:00
Robert Stanca
93242cf5a6 py3: use absolute_import in killdaemons.py 2016-04-16 05:29:29 +03:00
Matt Mackall
8f9dbd2fd0 tests: make killdaemons.py use DAEMON_PIDS by default 2015-06-08 14:21:45 -05:00
Augie Fackler
02bdc3f67d python3: update killdaemons and run-tests print and exception syntax
test-run-tests.t still passes fine on Python 2.6. run-tests.py --local
no longer fails with syntax errors, and now fails looking for xrange.

Most changes done with

2to3 -w -f numliterals -f except -f print tests/run-tests.py tests/killdaemons.py

after which one import was fixed in run-tests and a __future__ import
was added.
2015-04-11 18:20:44 -04:00
Yuya Nishihara
63bc6388d0 killdaemons: correct typo of _check() function caught by pyflakes 2014-04-29 12:37:36 +09:00
Augie Fackler
30760aaf72 killdaemons: drop superfluous L suffix from constant
As far as I'm aware PEP 237[0] means this suffix is superfluous even
on Python 2.4, and we can just drop it, which makes this code happy on
Python 3.

0: http://legacy.python.org/dev/peps/pep-0237/
2014-03-10 17:52:42 -04:00
Simon Heimberg
2c8f3e258b tests: killdaemons.py for windows distinguishes access violation and terminated
To distinguish between access violaition (process belonging to another user)
and a terminated process, PROCESS_QUERY_INFORMATION must be enabled. But
TerminateProcess still raises error 5 in both cases. Therefore check before if
the process has already terminated.
2014-02-12 16:09:18 +01:00
Simon Heimberg
ad307f52ea tests: killdaemons.py for checks reason when getting no process handle 2014-02-12 15:38:59 +01:00
Simon Heimberg
700d7ff53a tests: killdaemons.py for windows waits for killed process to terminate
After kill, wait for the process to terminate. When it does not in time,
write a debug message similar as in other os. But no 2nd forceful attempt
is done.
2014-01-17 21:13:20 +01:00
Simon Heimberg
b0d67373c0 tests: kill for windows in killdaemons.py checks return values
The return values of the windll calls are checked and when an error is
indicated, it is raised. The handle is still closed properly.
2014-01-17 21:13:08 +01:00
Patrick Mezard
7d8680da1f killdaemons: take file argument explicitely
It makes it easier to use as a generic replacement for kill utility,
mostly for Windows tests.
2012-08-20 22:36:51 +02:00
Patrick Mezard
d56e57416a killdaemons: add windows implementation 2012-08-19 18:06:15 +02:00
Patrick Mezard
50b52183c2 run-tests: do not duplicate killdaemons() code 2012-08-19 16:41:09 +02:00
Nicolas Dumazet
7f1a963829 pylint, pyflakes: remove unused or duplicate imports 2010-04-14 17:58:10 +09:00
Alejandro Santos
77d606ac51 compat: use open() instead of file() everywhere 2009-07-05 11:01:30 +02:00
Dirkjan Ochtman
1763cebde5 tests: make killdaemons.py executable 2008-11-07 23:56:02 +01:00
Matt Mackall
eed64a7674 tests: add killdaemons helper script 2008-11-07 16:28:53 -06:00