osx - Getting a crash in NSTask -
i've had report field of crash @ -launch on nstask.
the code in question is:
nstask *task = [[nstask alloc] init]; [task setlaunchpath:@"/bin/zsh"]; if(ignore) { [task setarguments:@[scriptpath, recordingfolder, argument]]; } else { [task setarguments:@[scriptpath, recordingfolder]]; } nspipe *outpipe = [nspipe pipe]; [task setstandardoutput:outpipe]; nspipe *errorpipe = [nspipe pipe]; [task setstandarderror:errorpipe]; [task launch]; the scriptpath script included in app bundle. crash says:
*** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'failed set posix_spawn_file_actions fd -1 @ index 0 errno 9' what cause of this? file descriptor posix_spawn_file_actions refer to? mean executable script wrong or outpipe or errpipe not formed?
i believe referring posix_spawn function: https://developer.apple.com/library/mac/documentation/darwin/reference/manpages/man2/posix_spawn.2.html
and errno 9 ebadf (bad file number).
i've got similar error , after use below command, it's ok, can try it.
nsfilehandle *file=[outpipe filehandleforreading]; [task launch]; ....//read file. //this important. [file closefile];
Comments
Post a Comment