[launchd-dev] How to remove/unload anonymous job labels?

Damien Sorresso dsorresso at apple.com
Thu Jul 16 23:05:09 PDT 2009


On Jul 16, 2009, at 10:41 PM, Conrad Taylor wrote:
> I have created a plist for MySQL that should start on demand on  
> PowerMac G5 using Mac OS 10.5.7.  However, when I look at the  
> process list, I'm seeing the following:
>
>   116   ??  S      0:00.04 /bin/sh ./bin/mysqld_safe --datadir=/usr/ 
> local/mysql/data --pid-file=/usr/local/mysql/data/darnoc- 
> desktop.local.pid
>   143   ??  S      0:01.61 /usr/local/mysql/bin/mysqld --basedir=/ 
> usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --pid- 
> file=/usr/local/mysql/data/darnoc-desktop.local.pid
>
> Note:  After rebooting the machine, I'm seeing the following:
>
> sudo launchctl list | grep mysql
>
> 143	-	0x10c5d0.mysqld
> 143	-	0x10b430.mysqld

I'm betting that mysqld did something that launchd jobs aren't  
supposed to do, like calling daemon(2) or the moral equivalent by fork 
(2)ing and then exiting the parent.

> Now, when I perform the following on MacBook Pro:
>
> sudo launchctl unload -w /opt/local/etc/LaunchDaemons/ 
> org.macports.mysql5/org.macports.mysql5.plist
>
> sudo launchctl list | grep mysql
>
> <no results>

You unloaded the job, so that's to be expected.

> sudo launchctl load -w /opt/local/etc/LaunchDaemons/ 
> org.macports.mysql5/org.macports.mysql5.plist
>
> sudo launchctl list | grep mysql
>
> 232	-	0x100119dc0.anonymous.mysqld
> 202	-	org.macports.mysql5

mysqld probably fork(2)ed, and the child tried talking to launchd.  
That's where the anonymous job comes from.

> Would it be possible to put job in a bad state if you edit its plist  
> file while it's loaded?

No. Your job isn't in a bad state.

> At this time, I
> can connect to the MySQL process without getting a connection error  
> even when the job is loaded.

You're supposed to be able to connect to the server when the job is  
loaded. What exactly is the bug you're experiencing?
-- 
Damien Sorresso
BSD Engineering
Apple Inc.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2425 bytes
Desc: not available
URL: <http://lists.macosforge.org/pipermail/launchd-dev/attachments/20090716/14e45cbb/attachment.bin>


More information about the launchd-dev mailing list