Я пытаюсь создать приложение с 2 кнопками: «Пуск» и «Стоп».
При нажатии кнопки «Пуск» должна быть запущена команда терминала:
yes > /dev/null & yes > /dev/null & yes > /dev/null &
Должна работать кнопка «Стоп»:
killall yes
Мне также интересно, можно ли запустить приложение на каждой ОС c.
Мой код
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
func applicationDidFinishLaunching(_ aNotification: Notification) {
}
func applicationWillTerminate(_ aNotification: Notification) {
}
@IBAction func StartStress(_ sender: NSButton) {
let path = "/varun-kaddichha$/Desktop/MacStressTest/stress.sh"
let arguments = ["/varun-kaddichha$/Desktop/MacStressTest/stress.sh"]
sender.isEnabled = false
let task = Process.launchedProcess(launchPath: path, arguments: arguments)
task.waitUntilExit()
sender.isEnabled = true
}
}
Мой bash файл
#! /bin/bash
do shell script "yes > /dev/null & yes > /dev/null & yes > /dev/null & yes > /dev/null & yes > /dev/null & yes > /dev/null & "