sending control+c (SIGINT) to NSPIPE in objective-c
- by Ron
Hello,
I am trying to terminate an openvpn task, spawned via NSTask.
My question:
Should I send ctrl+c (SIGINT) to the input NSPipe for my NSTask?
inputPipe = [NSPipe pipe];
taskInput = [inputPipe fileHandleForWriting];
NSString dataString = @"\cC";
[taskInput writeData:[dataString dataUsingEncoding: [NSString defaultCStringEncoding]]];
Alternatively, I was thinking about using kill( pid, SIGINT ); but it would be much more complicated since the process ID has to be determined via a detour ([task processIdentifier] does not help here) - the original NSTask calls:
/bin/bash -c sudo -S | mypassword ....
That's not nice, I know but it is only called once and the sudo password has been entered in that case already.
thanks for any suggestions/opinions/etc.
Ron