Opened 11 years ago

Last modified 11 years ago

#2779 defect new

os.setsid throws exception in PTYProcess on AIX

Reported by: chrispritchard Owned by: chrispritchard
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:


On the AIX platform it appears that if you have already used the TIOCNOTTY command to detach from the terminal you will get an exception thrown when doing an os.setsid() call, which causes the rest of the code in the child of the fork to be aborted. IIUC there is no need to do both of these types of detachment. Adding an else case to the

if hasattr(termios, 'TIOCNOTTY'):

containing the os.setsid() appears to fix the problem

Change History (7)

comment:1 Changed 11 years ago by jknight

as seen here:

We shouldn't need to do TIOCNOTTY if setsid works. The other way around is not the case.

comment:2 Changed 11 years ago by chrispritchard

Is it valid to assume that a call to os.setsid() has worked provided it did not throw an exception? If so, I can rearrange my change so that the os.setsid() is first. On this AIX platform if you call os.setsid() *before* attempting the TIOCNOTTY it does work and does not throw. However when the program then attempts to open the tty this call throws still causing the rest of the child to be aborted.

comment:3 Changed 11 years ago by Glyph

Owner: changed from Glyph to chrispritchard

It would be helpful if you could:

  1. submit a patch, including unit test, for this behavior
  2. contribute an AIX buildbot for so that it can be a supported platform

Thanks for the bug report!

comment:4 Changed 11 years ago by chrispritchard

Actually the reason I am working on this problem is so that I can get buildbot to work on AIX, so I will update when I get there :-) I will also work on the patch as requested.

comment:5 Changed 11 years ago by Jean-Paul Calderone

#2341 is going to be merged any day now, so a lot of the code in this area is going to shuffle around. It shouldn't be too difficult to update a patch to apply to the new version, but you might want to look at that branch now anyway.

Also, it would probably make sense to factor the setsid/TIOCNOTTY code into a function which can be tested independently, and perhaps have different implementations on different platforms (although that may not actually be necessary in this case).

comment:6 Changed 11 years ago by jknight

My first inclination would be to simply remove the TIOCNOTTY bit completely, unless we have a platform where setsid doesn't exist. But as unix tty stuff is all quite hairy, I'd want to test that that does *actually* work right via some small (non-twisted process-code-using) test program before committing such a change.

comment:7 Changed 11 years ago by chrispritchard

When you say "non-twisted process-code-using" do you mean a Python program doing os.fork() / os.setsid() and similar? I'd like to help test this if I can. I have a lab here with most platforms available and can provide test results if it helps.

Note: See TracTickets for help on using tickets.