Re: PgAgent - return code on batch step on Windows

From: Dave Page <dpage(at)pgadmin(dot)org>
To: Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: pgadmin-support(at)postgresql(dot)org
Subject: Re: PgAgent - return code on batch step on Windows
Date: 2010-11-22 12:59:29
Message-ID: AANLkTi=WbaKasCjyxRGpHdUgzdJcN6KTE6zJ62_maFzz@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

On Mon, Nov 22, 2010 at 12:06 PM, Julien Rouhaud <rjuju123(at)gmail(dot)com> wrote:
> Hi pgadmin team.
>
> I got a problem with PgAgent on Windows :
> When I create a batch step, the status is always set to succeed, even if the
> batch doesn't work.
>
> I found  this in the source code (job.cpp) :
>
> #ifdef __WIN32__
>                 // The Windows way
>                 HANDLE h_script;
>                 DWORD dwRead;
>                 char chBuf[4098];
>
>                 h_script = win32_popen_r(filename.wc_str());
> [...]
>                 CloseHandle(h_script);
>                 rc=1;
> #else
>                 // The *nix way.
> [...]
>                 rc=pclose(fp_script);
>         rc = (unsigned char)(rc >> 8); // The exit code is in the top 8 bits
>         rc = (signed char)rc;
>
> the return code seems to be always true on windows platform, as the
> CloseHandle return code is not used ?
> Hope that'll help.

CloseHandle is a generic function that returns a boolean indicating
whether or not the handle was closed - it really doesn't tell us
anything useful about what happened, unlike pclose().

Does something like this work?

diff --git a/job.cpp b/job.cpp
index 0611c93..08feb17 100644
--- a/job.cpp
+++ b/job.cpp
@@ -258,9 +258,8 @@ int Job::Execute()
}
}

-
+ GetExitCodeProcess(h_script, (LPDWORD)&rc);
CloseHandle(h_script);
- rc=1;

#else
// The *nix way.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgadmin-support by date

  From Date Subject
Next Message Julien Rouhaud 2010-11-22 13:18:49 Re: PgAgent - return code on batch step on Windows
Previous Message Julien Rouhaud 2010-11-22 12:06:17 PgAgent - return code on batch step on Windows