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

Test for process.terminal fails #29

Open
k4rtik opened this issue Jan 1, 2016 · 4 comments
Open

Test for process.terminal fails #29

k4rtik opened this issue Jan 1, 2016 · 4 comments
Labels
Milestone

Comments

@k4rtik
Copy link
Contributor

k4rtik commented Jan 1, 2016

=========================== FAILURES ===========================
___________________________ test_process ____________________________

flush = None

    def test_process(flush):
        cpid = os.getpid()
        psu = psutil.Process(cpid)
        psl = P.get_process(cpid)
        assert psu.pid == psl.pid
        assert psu.ppid() == psl.ppid
        assert psu.name() == ffi.string(psl.name)
        assert psu.exe() == ffi.string(psl.exe)
        assert " ".join(psu.cmdline()) == ffi.string(psl.cmdline)
        assert psu.create_time() == psl.create_time
        uids = psu.uids()
        assert uids.real == psl.uid
        assert uids.effective == psl.euid
        assert uids.saved == psl.suid
        gids = psu.gids()
        assert gids.real == psl.gid
        assert gids.effective == psl.egid
        assert gids.saved == psl.sgid
        assert psu.username() == ffi.string(psl.username)
>       assert psu.terminal() == ffi.string(psl.terminal)
E       assert '/dev/pts/2' == '/dev/null'
E         - /dev/pts/2
E         + /dev/null

test_process.py:26: AssertionError
==================== 1 failed, 16 passed in 4.08 seconds ===================
@k4rtik
Copy link
Contributor Author

k4rtik commented Jan 8, 2016

Spent some time on this yesterday. The problem is using any of the default file descriptors (0, 1 or 2) for a process to obtain the terminal name (as done at nibrahim@e6f5eaf#diff-bf673c7ccb2de4138124fef0d870a1cdR210) is not reliable. I tried using fd 1 and 2 instead of 0 and instead of /dev/null I received paths inside of /tmp/ when py.test is invoked.

For the OS X port, I was able to use devname() syscall but that is specific to BSD systems. The only correct way to do this (that I could find) was to use the same approach as psutil (maintain a map for controlling terminal number with device names, obtain the number (key) from /proc/pid/stat and then query the map).

@k4rtik
Copy link
Contributor Author

k4rtik commented Jan 8, 2016

@nibrahim BTW, does the test not fail at your end?

@nibrahim
Copy link
Collaborator

nibrahim commented Jan 9, 2016

I don't think so. I'll look at all the bugs you've filed early next week
and we can chat to decide direction.

Cordially,
Noufal
http://nibrahim.net.in

@k4rtik
Copy link
Contributor Author

k4rtik commented Jan 17, 2016

Confirming that this fails on my dept's regular Debian 8 machines as well.

@k4rtik k4rtik added this to the 1.0.0-beta milestone Jan 17, 2016
@k4rtik k4rtik added the bug label Jan 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants