>> > Robustly turning a string that happens to be a file system path into an
>> > identifier for a running process is the tricky part of this. I haven't
[quoted text clipped - 7 lines]
> Except for apps that moved since launch, depending on when and how the
> path the OP was handed was constructed.
Well, if he has a path to where the app actually *is*, and not where it
once *was*, then this will still work, since the FSRefs will follow the
move. If he only has a path to where the app once was, then nothing short
of a guessing game will work without a time machine. But I wouldn't count
that in your 1%, because it's a pathological case, like saying that
Spotlight won't find a file by name if you've changed the name.

Signature
Michael Ash
Rogue Amoeba Software
Gregory Weston - 28 Sep 2007 19:01 GMT
> >> > Robustly turning a string that happens to be a file system path into an
> >> > identifier for a running process is the tricky part of this. I haven't
[quoted text clipped - 14 lines]
> that in your 1%, because it's a pathological case, like saying that
> Spotlight won't find a file by name if you've changed the name.
Spotlight'll still work if you change the name of any number of
nonterminal nodes in the path. People do rename volumes and folders from
time to time. I think the real answer to "How can I terminate a process
given a path" is "first look to see if you can get something better like
a bundle ID or creator code." Even an alias would be more reliable.
Michael Ash - 28 Sep 2007 21:31 GMT
>> Well, if he has a path to where the app actually *is*, and not where it
>> once *was*, then this will still work, since the FSRefs will follow the
[quoted text clipped - 8 lines]
> given a path" is "first look to see if you can get something better like
> a bundle ID or creator code." Even an alias would be more reliable.
Yes, a lot depends on where the path comes from. I had taken the "path to
the app" as a given, rather than assuming it's "a path which was once to
the app".
If the path comes from, say, an open panel which just finished running
then you're pretty safe, aside from the race conditions inherent in any
use of paths which nobody seems to want to talk about.
If the path comes out of preferences or something then you're right and
it's just plain the wrong approach to use in the first place. Storing the
bundle ID would be the right way to proceed in this case, IMO.

Signature
Michael Ash
Rogue Amoeba Software