DC_getResultExit implemented.

DC_getResultOutput can now give back stdout and stderr files.



git-svn-id: svn+ssh://cvs.lpds.sztaki.hu/var/lib/svn/szdg/dcapi/trunk@491 a7169a2c-3604-0410-bc95-c702d8d87f7a
This commit is contained in:
vida 2006-05-02 08:01:58 +00:00 committed by Adam Visegradi
parent 4cfba68cbc
commit ff35787944
1 changed files with 39 additions and 3 deletions

View File

@ -5,6 +5,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "dc_local.h"
@ -59,7 +62,7 @@ void _DC_destroyResult(DC_Result *result)
unsigned DC_getResultCapabilities(DC_Result *result)
{
return (DC_GC_STDOUT | DC_GC_STDERR);
return (DC_GC_STDOUT | DC_GC_STDERR | DC_GC_EXITCODE);
}
DC_Workunit *DC_getResultWU(DC_Result *result)
@ -69,9 +72,26 @@ DC_Workunit *DC_getResultWU(DC_Result *result)
int DC_getResultExit(DC_Result *result)
{
// XXX Not impl.
int status;
pid_t retval, pid;
return 0;
pid = (pid_t)result->wu->pid;
retval = waitpid(pid, &status, WNOHANG);
if (retval != pid)
{
DC_log(LOG_ERR, "DC_getResultExit: wu with pid %d not exited according to waitpid. retval: %d",
pid, retval);
return -1;
}
if (!WIFEXITED(status))
{
DC_log(LOG_WARNING, "DC_getResultExit: wu with pid %d terminated not normally.", pid);
return -1;
}
return WEXITSTATUS(status);
}
char *DC_getResultOutput(DC_Result *result, const char *logicalFileName)
@ -90,6 +110,22 @@ char *DC_getResultOutput(DC_Result *result, const char *logicalFileName)
}
}
if (!strcmp(logicalFileName, DC_RESULT_STDOUT))
{
char *tmp = g_strdup_printf("%s%c%s", result->wu->workdir, G_DIR_SEPARATOR, STDOUT_LABEL);
physicalFileName = strdup(tmp);
g_free(tmp);
return physicalFileName;
}
if (!strcmp(logicalFileName, DC_RESULT_STDERR))
{
char *tmp = g_strdup_printf("%s%c%s", result->wu->workdir, G_DIR_SEPARATOR, STDERR_LABEL);
physicalFileName = strdup(tmp);
g_free(tmp);
return physicalFileName;
}
DC_log(LOG_ERR, "DC_getResultOutput: The %s file is not part of the given result", logicalFileName);
return NULL;