• Post Reply Bookmark Topic Watch Topic
  • New Topic

Should the streams in process be closed inspite of calling destroy  RSS feed

 
Vinay B K
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi my code does not need the output stream , should I still close the output stream irrespective of calling destroy method of process
 
Tony Docherty
Bartender
Posts: 3268
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No you don't need to close the streams. The streams will be closed when the process terminates, either naturally or by calling destroy().

To be honest I'm not sure what the implication are, if any, of closing the streams yourself. I know Process is prone to deadlocks when the streams buffers fill up but I've no idea what happens if you close a stream whilst the process is still running.
 
Tony Docherty
Bartender
Posts: 3268
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BTW if you are dealing with Process' I suggest you read "When Runtime.exec() won't", it's full of useful advice and common gotchas.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!