Re: running shell in background....
Re: running shell in background....
- Subject: Re: running shell in background....
- From: "Mark J. Reed" <email@hidden>
- Date: Mon, 3 Sep 2007 08:44:06 -0400
There are real questions here that involve the way that Apple has added its GUI - Aqua - to the UNIX of old.
It's all pretty much what you would expect, as far as I can tell. I'll try to answer.
Who
does "own" the background application or script that gets started? By
own I'm talking about the hierarchy of processes that UNIX is where
every process is started by another which remains its parent, or at
least is supposed to.
The shell started by "do shell script" is a child of the Applescript interpreter executing the statement. Neither Terminal.app nor any other GUI terminal program is involved. Nor is a pseudo-terminal allocated. The shell is not attached to any terminal, and if you check for such using the usual shell tricks, that will be revealed: -t ("is terminal?") returns false on standard input, output, and error; the $- flags variable doesn't include "i" ("interactive"); etc. Which is why I put "terminal" in quotes in my reply; it's really just some file descriptors that stay open.
What is the parentage of
a background process that has been started by a previously logged in
GUI user. Does it continue to run? To whom is a child died event sent?
Can someone with the right privileges attach to it for control through
ssh? Is it practical to start up, say, a daemon from a do shell script
that would monitor a port or become a recipient on a named pipe?
The answers are the same as for any other UNIX environment. A process which keeps running after its parent exits is essentially orphaned; its parent PID is set to 1 (init on most UNIXes, launchd on OS X). And there is no adoption: processes cannot in general be reparented. There are ways to "attach" to a running process for debugging etc, but they don't change the attachee's parentage.
The
more I think about it the more I think initiating background processes
ought to be carefully controlled for security purposes.
A process left running by a user does not have any more privileges than a process running in the foreground by that user. And only the user currently logged into the console can interact with the GUI session. The risk of background processes is no greater than the risk of invisible GUI apps or any other executable that a normal user can start up...
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden