launch_daemon: Improved error reporting, minor cleanup.
This commit is contained in:
@@ -6,7 +6,9 @@
|
|||||||
|
|
||||||
#include "BaseJob.h"
|
#include "BaseJob.h"
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
@@ -103,10 +105,10 @@ BaseJob::SetEnvironment(const BMessage& message)
|
|||||||
for (int32 index = 0; message.GetInfo(B_STRING_TYPE, index, &name, &type,
|
for (int32 index = 0; message.GetInfo(B_STRING_TYPE, index, &name, &type,
|
||||||
&count) == B_OK; index++) {
|
&count) == B_OK; index++) {
|
||||||
if (strcmp(name, "from_script") == 0) {
|
if (strcmp(name, "from_script") == 0) {
|
||||||
const char* fromFile;
|
const char* fromScript;
|
||||||
for (int32 fileIndex = 0; message.FindString(name, fileIndex,
|
for (int32 scriptIndex = 0; message.FindString(name, scriptIndex,
|
||||||
&fromFile) == B_OK; fileIndex++) {
|
&fromScript) == B_OK; scriptIndex++) {
|
||||||
fSourceFiles.Add(fromFile);
|
fSourceFiles.Add(fromScript);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -166,6 +168,7 @@ BaseJob::_GetSourceFileEnvironment(const char* script, BStringList& environment)
|
|||||||
pid_t child = fork();
|
pid_t child = fork();
|
||||||
if (child < 0) {
|
if (child < 0) {
|
||||||
// TODO: log error
|
// TODO: log error
|
||||||
|
debug_printf("could not fork: %s\n", strerror(errno));
|
||||||
} else if (child == 0) {
|
} else if (child == 0) {
|
||||||
// We're the child, redirect stdout
|
// We're the child, redirect stdout
|
||||||
close(STDOUT_FILENO);
|
close(STDOUT_FILENO);
|
||||||
|
|||||||
Reference in New Issue
Block a user