It is currently Wed Oct 21, 2020 2:51 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: CloseProgram leaves zombie processes
PostPosted: Sat Sep 26, 2020 9:16 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jan 12, 2011 3:48 pm
Posts: 217
Location: Serbia
This will create around 20 zombie processes, can be seen in pstree or just use 'ps ax | grep echo'.

Code:
OpenWindow(0,100,100,400,300,"run program test")

For i = 1 To 100
  pid = RunProgram("/bin/echo","111","",#PB_Program_Write|#PB_Program_Open)
  CloseProgram(pid)
Next

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

_________________
PB examples collection
pb-osx-globalhotkeys
pb-osx-notifications


Top
 Profile  
Reply with quote  
 Post subject: Re: CloseProgram leaves zombie processes
PostPosted: Sat Sep 26, 2020 12:13 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jan 12, 2011 3:48 pm
Posts: 217
Location: Serbia
Launching the process and writing to it directly through Cocoa doesn't leave any zombie processes:
Code:
  task = CocoaMessage(0,CocoaMessage(0,0,"NSTask alloc"),"init")
  CocoaMessage(0,task,"setLaunchPath:$",@"/bin/echo")
  writePipe = CocoaMessage(0,0,"NSPipe pipe")
  writeHandle = CocoaMessage(0,writePipe,"fileHandleForWriting")
  CocoaMessage(0,task,"setStandardInput:",writePipe)
  CocoaMessage(0,task,"launch")
  string = CocoaMessage(0,0,"NSString stringWithString:$",@"111")
  string = CocoaMessage(0,string,"dataUsingEncoding:",#NSUTF8StringEncoding)
  CocoaMessage(0,writeHandle,"writeData:",string)
  CocoaMessage(0,writeHandle,"closeFile")
  CocoaMessage(0,task,"release")


UPD: I'm aware that passing an argument and writing to stdin are two different things, i just wasn't sure what #PB_Program_Write does under the hood so i decided it would make sense to write a full writing procedure on Cocoa.

_________________
PB examples collection
pb-osx-globalhotkeys
pb-osx-notifications


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye