Xcode, using widget.system. Limitations?

Discussion in 'Mac Programming' started by magn2o, Sep 22, 2008.

  1. macrumors member

    So I started writing a Dashboard widget.. and so far, everything is working with the exception of one little part that is driving me nuts.

    A quick snippet,

    sshPid = widget.system("/usr/bin/ssh [args] &>/dev/null & echo $!", null).outputString; // Grabs pid of executed process
    widget.system("/bin/kill -9 " + sshPid, null); // kill process
    Now, the first part works fine. The process is executed, and the pid is stored within sshPid, however, the second part is where it seems to fail. It doesn't kill the process. For the life of me, I cannot figure out why. I've verified the command, I've even hardcoded it, still, it won't work. Is there a restriction on /bin/kill?

    I'm beating my head on a wall over here..
  2. macrumors 68040


    As long as you own the process you are trying to kill, there shouldn't really be any restrictions.

    What if you just put a wait in your widget, and go to the terminal and try to kill the process manually, and see what the result is?

    Are you remotely executing something with your SSH command? How do you know it's done so quickly after running it?

  3. macrumors member

    Well, the above code isn't the exact implementation. It's a widget that allows me to start and stop a ssh tunnel and dns-sd process for remote DAAP sharing. The processes are killed via the STOP button on the widget. I probably should have elaborated on that in the first post, sorry.

    Oh, and I can kill the processes manually just fine.
  4. macrumors 68040


    At this point, then, i'd redirect the kill output and stderr to a file (or if there's some method to get those with widget.system, do so) and see if kill is issuing some sort of error. I doubt there's a limit in widget.system to things you can run, but that's speculation.


Share This Page