isatty vs notatty mac

Post Reply
JimH
Posts: 54
Joined: Tue Apr 10, 2007 3:36 pm
Location: Duke University

isatty vs notatty mac

Post by JimH »

I've using Java to do ipc with NEURON on a mac. I've setup something similar using .NET on windows (and Java) and had some success. When I tried the Java code on my mac, I would not get any input back from the process.

I was using the option -isatty. Changing the option to -notatty made things work, sort of.
Specifically:
-notatty seems to flush on command execution
-notatty does not provide the oc> prompt

I have not yet tried reading from the process after it has been destroyed. Currently my code is setup not to read the from the stream if the process has been destroyed.

the stderr stream works as I am able to get the banner output which is placed on the error stream. This is for both -isatty and -notatty

I am using the current mac download 7.2 10.8.0 dmg on osx 10.8.2

Is it possible that the code was switched so that notatty does the flushing and isatty does not?
JimH
Posts: 54
Joined: Tue Apr 10, 2007 3:36 pm
Location: Duke University

Re: isatty vs notatty mac

Post by JimH »

I also just confirmed that -isatty does flush upon quitting the process => quit()
which I thought would happen for -notatty
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: isatty vs notatty mac

Post by hines »

My intention was that
-isatty unbuffered stdout, print prompt when waiting for stdin
-notatty buffered stdout and no prompt
and so -isatty was supposed to be convenient when one ipc progam was sending commands to nrniv and receiving back the result. (and would know nrniv was ready
for the next command when the prompt came back.

I guess I would expect both to flush on quit()

Anyway, the test that this kind of thing works is to try
ssh localhost nrniv -isatty
is that working on your mac?
JimH
Posts: 54
Joined: Tue Apr 10, 2007 3:36 pm
Location: Duke University

Re: isatty vs notatty mac

Post by JimH »

That makes sense. What I am seeing on my mac is:
- isatty buffered stdout, not sure about prompt, waits until program close to flush
- notatty, unbuffered stdout, no prompt, flushes when waiting for stdin

This is in contrast to my windows install of 7.2 which works as would be expected.

I tried the ssh test (based on another post of yours) and it just seemed to be waiting. However, I did notice that if I typed nonsense I would get errors back. I never actually tested quitting.

This problem was originally pointed out to me by a student trying to use my code on a mac using osx 10.6 who also downloaded the currently posted dmg file. In other words, I think the problem might be with the posted version, not my mac.

Thanks,
Jim
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: isatty vs notatty mac

Post by hines »

I've reproduced the bad behavior of -isatty on my mac and, for reasons unknown to me, the problem seems to be that
the libreadline library that comes with OS X does not do what I thought it should in these circumstances. The work-around
was to build and link against my own ancient version of readline (that is done with the configure option --with-readline= no). Now my test with ssh is successful.
Anyway, try the version
http://www.neuron.yale.edu/ftp/neuron/v ... 10.8.2.dmg

When your program launches nrniv, you may also wish to try the arguments -nogui and -nobanner
JimH
Posts: 54
Joined: Tue Apr 10, 2007 3:36 pm
Location: Duke University

Re: isatty vs notatty mac

Post by JimH »

When testing the code with the provided alpha version the terminal returns a message about an "Illegal Instruction" and the process closes.

The 7.2 code will work fine. Since we were having problems with our stdin parser, we added on a magic string to our stdout following every command, which contains instructions to print the string in Neuron, which subsequently gets parsed by our stdin to let us know our command has finished. In other words, it is a relatively simple fix to get around the lack of oc> prompts, as long as we get messages during code execution and not at the end of the program. Thus at this point we're all set with using -notatty on Mac for 7.2.

Thanks for all the help with this and other issues.

Jim
hines
Site Admin
Posts: 1682
Joined: Wed May 18, 2005 3:32 pm

Re: isatty vs notatty mac

Post by hines »

I'm concerned, of course, with the illegal instruction problem. I've seen that when linking on mountain lion (10.8) and trying to run on lion (10.7).
But it seems clear above that you do indeed have 10.8. So it's pretty much of a puzzle to me for now. Let me know if you wish to pursue it.
Sounds like you are happy enough with your present solution.
Post Reply