Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

magn2o

macrumors member
Original poster
Sep 22, 2008
43
0
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,

Code:
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

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
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

macrumors member
Original poster
Sep 22, 2008
43
0
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

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.