[launchd-dev] Attaching to launchd via gdb?

Dave Zarzycki zarzycki at apple.com
Thu Nov 15 14:28:23 PST 2007


Traditionally, the kernel doesn't allow debuggers to attach to PID 1.  
As the author of launchd, I haven't felt strong enough to get the  
kernel team to change that policy. I've learned to live with logging.  
You can enable logging by adding "log level debug" to /etc/ 
launchd.conf and adjusting /etc/syslog.conf to capture the generated  
messages.

Having said all that, based on the messages below, I'd be curious to  
figure how why those processes are running around with UID 166128603.  
Was that ever a valid UID on your system? For whatever it may be  
worth, getpwuid() is a shim around DirectoryService APIs and the  
DirectoryService daemon. I'd try to get in contact with them.

davez



On Nov 15, 2007, at 12:39 PM, Matt DeFoor wrote:

> Is there a means to attach to and debug launchd? Or to attach to a per
> user launchd process? I get the following when logged in as root and
> trying to attach to launchd:
>
> (gdb) attach launchd.1
> Attaching to program: `/sbin/launchd', process 1.
> Unable to attach to process-id 1: Operation not permitted (1).
> This request requires that the target process be neither setuid nor
> setgid and have the same real userid as the debugger, or that the
> debugger be running with administrator privileges.
>
> I'm trying to determine why the call to getpwuid() in
> job_postfork_become_user() is failing. Here's a snippet from
> system.log:
>
> Nov 15 14:39:35 dc3 com.apple.launchd[1]
> (com.apple.launchd.peruser.166128603[1036]): getpwuid("166128603")
> failed
> Nov 15 14:39:35 dc3 com.apple.launchd[1]
> (com.apple.launchd.peruser.166128603[1036]): PID 1002
> "authorizationhos" has no account to back it! Real/effective/saved
> UIDs
> : 0/166128603/0
> Nov 15 14:39:35 dc3 com.apple.launchd[1]
> (com.apple.launchd.peruser.166128603[1036]): PID 112
> "authorizationhos" has no account to back it! Real/effective/saved
> UIDs:
> 0/166128603/0
> Nov 15 14:39:35 dc3 com.apple.launchd[1]
> (com.apple.launchd.peruser.166128603[1036]): Exited with exit code: 1
> Nov 15 14:39:35 dc3 com.apple.launchd[1]
> (com.apple.launchd.peruser.166128603): Throttling respawn: Will start
> in 10 seconds
>
> Cheers,
> Matt
> _______________________________________________
> launchd-dev mailing list
> launchd-dev at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo/launchd-dev



More information about the launchd-dev mailing list