nstask

Sandbox with NSTask

北慕城南 提交于 2019-12-07 11:25:38
问题 I have sandboxing enabled and use /sbin/ping with NSTask: [task setLaunchPath:@"/sbin/ping"]; [task setArguments:[NSArray arrayWithObjects:@"-c10", iPAddress, nil]]; Everything works great and I get the expected output. I also want to use /usr/sbin/traceroute with NSTask: [task setLaunchPath:@"/usr/sbin/traceroute"]; [task setArguments:[NSArray arrayWithObject:iPAddress]]; But the task terminates with the message: NSTask: Task create for path '/usr/sbin/traceroute' failed: 22, "Invalid

Trying to use cydia libraries: NSTask on Jailbroken iphone crashes with Segmentation fault: 11

旧时模样 提交于 2019-12-07 10:29:16
问题 I want to run dpkg ( or any other binary library files from cydia in the /bin or /usr/bin directories) from a GUI app with an icon, like mobileterminal, ifile, myfile, cydia, alertscript, and so many others can. How do they accesses the libraries? This code works, and the stdout of the process is printed in nslog but then it immediately crashes with Segmentation fault: 11. this is in my viewdidload function. This DOES NOT OCCUR IN THE SIMULATOR, only my iPhone 4. weird. have tried running as

How can I reload the com.apple.systemuiserver preferences into the SystemUIServer application?

匆匆过客 提交于 2019-12-07 07:25:44
问题 For my Mac OSX application, I have a feature that removes the system clock in the upper right hand corner of the screen when a button is clicked. The preferences that control which system menus are displayed (including the system clock) is stored in ~/Library/Preferences/com.apple.systemuiserver.plist. I was able to update the relevant preferences in that file to remove the system clock. However, the SystemUIServer application needs to be restarted so that the new preferences can be reloaded

Terminate an NSTask and its children

给你一囗甜甜゛ 提交于 2019-12-07 04:51:20
问题 I'm using NSTask to execute a series of long running commands like so: commandToRun = @"command 1;command2"; NSArray *arguments = [NSArray arrayWithObjects: @"-c", commandToRun, nil]; self.task = [[NSTask alloc] init]; [self.task setLaunchPath: @"/bin/sh"]; [self.task setArguments: arguments]; [self.task launch]; This creates a process for the shell, and a child process for whichever command is running at the time (command 1 or command 2). If I kill the task with [self.task terminate] it only

Ignoring user input while waiting for a task - Objective-C

淺唱寂寞╮ 提交于 2019-12-06 20:37:31
I have an app with a button 'convert'. When I click this button, the app starts a new process using NSTask and then greys out the button until the process finishes. My problem is, the app saves any clicks made by the user while it is waiting for the process to finish. So even though the button is grayed out, the user can click it and the process will immediately start again as soon as it finishes. I'm waiting for the process to finish using: [task waitUntilExit]; How do I ignore any user input while waiting for this task to finish? -[NSTask waitUntilExit] is, of course, a blocking call. That

How can you get information such as, users window for example using the NSTask class in Swift, for OSX apps?

穿精又带淫゛_ 提交于 2019-12-06 19:42:30
If I can explain my self better knowing if a user is running some particular program such as word or chrome, etc. I will try to update my question as I write code or find more information. Thank you (: You don't have to go through NSTask , you can use Cocoa's NSWorkspace to get the list of running applications: import Cocoa let apps = NSWorkspace.sharedWorkspace().runningApplications It returns an array of NSRunningApplication objects. Let's say you want the running applications names in an array: let appsNames = apps.flatMap { $0.localizedName } If you want to know for example if iTunes is

Strange GDB behaviour once application is deployed to a jailbroken iPhone

独自空忆成欢 提交于 2019-12-06 12:13:24
问题 Im trying to make an application which sends commands to GDB via NSTask and directs the output to the UITextView. It works well on the Mac (iOS Simulator). However, when deployed to the actual device (iPhone), it does not display any registers after the command "info registers" The code is as such : - (void)viewDidLoad { self.title = @"GDB"; NSLog(@"Pid for GDB execution is :%@", pid); UIBarButtonItem *btnClicked = [[UIBarButtonItem alloc] initWithTitle:@"Commands" style

Get Notification of task progress from NSTask

亡梦爱人 提交于 2019-12-06 11:52:52
问题 Any body have idea about getting notification from NSTask while NSTask is executed. I am unzipping a zip file using NSTask and need to show the unzip data progress in a NSProgressBar. I don't found any idea for doing such task.So that i show the value in progress bar. Need help for doing this task. Thanks in advance. 回答1: Use NSFileHandleReadCompletionNotification , NSTaskDidTerminateNotification notifications. task=[[NSTask alloc] init]; [task setLaunchPath:Path]; NSPipe *outputpipe=[[NSPipe

sudo chmod command from cocoa

安稳与你 提交于 2019-12-06 11:31:47
I would like to the run the following command from my Cocoa project. (hides the spotlight icon) sudo chmod 600 /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search I have found two ways how to call the command and get the following output 1) Using NSTask NSTask *writeTask = [[NSTask alloc] init]; [writeTask setLaunchPath:@"/bin/chmod"]; [writeTask setArguments: @[@"755",@"/System/Library/CoreServices/Search.bundle/Contents/MacOS/Search"]]; [writeTask launch]; >>chmod: Unable to change file mode on /System/Library/CoreServices/Search.bundle/Contents/MacOS/Search: Operation not

Launching command using NSTask returns error

[亡魂溺海] 提交于 2019-12-06 11:00:16
问题 I'd like to launch the following command from my application using NSTask: sudo -u myusername launchctl load /Library/LaunchAgents/com.google.keystone.agent.plist Here is a code I do: NSPipe *pipe = [NSPipe pipe]; NSTask *task = [[NSTask alloc] init]; [task setLaunchPath: @"/bin/sh"]; [task setCurrentDirectoryPath:@"/"]; [task setStandardError:pipe]; NSArray *arguments = nil; arguments = @[@"sudo", @"-u", @"myusername", @"launchctl", @"load", @"/Library/LaunchAgents/com.google.keystone.agent