PDA

View Full Version : Xcode, using widget.system. Limitations?




magn2o
Sep 22, 2008, 12:44 PM
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..



lee1210
Sep 22, 2008, 01:19 PM
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?

-Lee

magn2o
Sep 22, 2008, 01:23 PM
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?

-Lee

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.

lee1210
Sep 22, 2008, 01:39 PM
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.

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.

-Lee