Pass control + c (SIGINT) to NSPIPE in objective-C

I am trying to complete the openvpn task generated through NSTask.

My question is:

Should I send ctrl+ c(SIGINT) to the NSPipe input for my NSTask?

inputPipe = [NSPipe pipe]; 
taskInput = [inputPipe fileHandleForWriting];
NSString dataString = @"\cC";
[taskInput writeData:[dataString dataUsingEncoding: [NSString defaultCStringEncoding]]];

As an alternative, I was thinking about using kill (pid, SIGINT); but it would be much more complicated, since the process identifier should be determined using a workaround ([task processIdentifier] does not help here) - the initial NSTask calls:

/bin/bash -c sudo -S | mypassword ....

This is not good, I know, but it is called only once, and the sudo password has already been entered in this case.

+3
source share
1 answer

Control-C and SIGINT are not the same thing.

" tty", , -, delete .. , -C ( - intr) SIGINT .

, tty *, control-C .

pid SIGINT . , ( sudo root)....

* (pty), NSPipe, : -)

+3

Source: https://habr.com/ru/post/1742807/


All Articles