2017-12-06 12 views
0

Ich habe noch nie zuvor einen LaunchDaemon geschrieben, also fange ich mit einem ganz einfachen an. Selbst mein einfacher scheint nicht auszuführen.LaunchDaemon wird sofort beendet, läuft aber weiter, wenn ich es direkt ausführe

Ich benutze macOS Sierra 10.12.5.

EDIT: Mein system.log ist voll von den folgenden:

Dec 6 00:02:47 Michaels-Mac-mini com.apple.xpc.launchd[1] (com.frescologic.hello): Service only ran for 0 seconds. Pushing respawn out by 10 seconds. 
Dec 6 00:02:57 Michaels-Mac-mini com.apple.xpc.launchd[1] (com.frescologic.hello[1386]): Service could not initialize: 16F73: xpcproxy + 11769 [1505][34964CF1-9965-3B4D-ADC7-6FBC6669C56D]: 0x2 

Allerdings, wenn ich laufen hallo direkt von der Kommandozeile, es läuft weiter.

Meine Konfigurationsdatei:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 
<plist version="1.0"> 
<dict> 
    <key>Label</key> 
    <string>com.frescologic.hello</string> 
    <key>ProgramArguments</key> 
    <array> 
     <string>hello</string> 
     <string>world</string> 
    </array> 
    <key>KeepAlive</key> 
    <true/> 
</dict> 

Quelle My Daemons:

#include <stdio.h> 
#include <stdlib.h> 
#include <unistd.h> 

int 
main(int argc, const char * argv[]) 
{ 
    FILE *outFile; 

    if (argc != 2){ 

     fprintf(stderr, "Usage:\n $ %s world\n", argv[ 0 ]); 
     exit(1); 
    } 

    outFile = fopen("/tmp/foo", "w"); 
    if (outFile == NULL) exit(1); 

    while (1){ 
     fprintf(outFile, "%s\n", argv[ 1 ]); 
     sleep(10); 
    } 

    return 0; 
} 

Die entsprechenden Berechtigungen:

$ ls -l /Library/LaunchDaemons/com.frescologic.hello.plist 
[email protected] 1 root wheel 375 Dec 5 21:47 /Library/LaunchDaemons/com.frescologic.hello.plist 

und

$ ls -l /usr/local/libexec 
total 40 
-rwxr-xr-x 1 root wheel 18240 Dec 5 21:45 hello 

launchctl behauptet, es läuft:

$ sudo launchctl list | grep hello 
Password: 
- 78 com.frescologic.hello 

Aber ps nicht:

$ ps -ef | grep hello 
    501 737 387 0 10:38PM ttys000 0:00.00 grep hello 

und

$ ps -ax | grep hello 
    743 ttys000 0:00.00 grep hello 

Die Log-Datei existiert nicht:

$ cd /tmp 
$ ls 
com.apple.launchd.JOJDWGHX78 com.apple.launchd.oUj51Uvj6v 

Helfen Sie mir O-Stackoverflow Sie sind meine einzige Hoffnung!

Antwort

0

Stephane hat das auf [email protected] beantwortet. Fügen Sie der Eigenschaftsliste den Schlüssel "Programm" mit dem vollständigen Pfad der ausführbaren Datei hinzu:

<key>Program</key> 
<string>/usr/local/libexec/hello</string> 
Verwandte Themen