• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Starting a process and using STDIN/STDOU/STDERR

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I'm starting a linux interactive console application that uses the ncurses library, from my SWING application.

The program starts ok, but even if i don't do anything with the stdin stream object, it keeps sending line feed characters to the process. I guess this is some kind of weird stream initialisation from the spawned process (maybe due to ncurses).

The process uses wgetc to grab characters from stdin (i'm not completely sure about this).

Has anybody got any clue about what is going on ?

For info, here's the simplistic version of the source code i'm using:

 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know about constantly sending line feeds, but I don't think this code does what you want:


InputStreamReader.ready() only returns true if there is data already in the InputStreamReader's buffer. Unless you have a really short-lived process you may be running right past your output. If you have a long-lived process, you should have these reads in seperate threads because the output buffers can fill and then block, halting the spawned process.
 
C�dric Yhuel
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for this. My actual app uses three separate threads, one for stdout/stderr and waitfor.

I'm starting to think that this is due to some terminal initialisation (like noecho()) done in the console application. I tyhink i read somewhere that a process launched from a java program isn't attached to any terminal..

So a solution would be to launch something like xterm -e "ConsoleApp"
The only thing is that i'd like to hide the window that shows up after that call. Any idea ?
 
Can you hear that? That's my theme music. I don't know where it comes from. Check under this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic