NAME

gbatch_jobmon - monitor changes to the job queue


SYNOPSIS

#include <gbatch.h>

int gbatch_jobmon(const int fd, void (*fn)(const int))

int gbatch_setmon(const int fd, HWND hWnd, UINT wMsg)

int gbatch_procmon(const int fd)

void gbatch_unsetmon(const int fd)


DESCRIPTION

Unix and Linux

The function gbatch_jobmon() is used to set a function to monitor changes to the job queue.

fd is a file descriptor which was previously returned by a successful call to gbatch_open(3).

fn is a pointer to a function which must be declared as returning void and taking one const int argument. Alternatively, this may be NULL to cancel monitoring.

The function fn will be called upon each change to the job list. The argument passed will be fd. Note that any changes to the job queue are reported (including changes on other hosts whose details are passed through) as the API does not record which jobs the user is interested in.

Windows

The gbatch_setmon routine may be used to monitor changes to the job queue or variable list. Its parameters are as follows.

fd is a file descriptor previously returned by gbatch_open.

hWnd is a windows handle to which messages should be sent.

wMsg is the message id to be passed to the window (WM_USER or a constant based on this is suggested).

To decode the message, the gbatch_procmon is provided. This returns XBWINAPI_JOBPROD to indicate a change or changes to the job queue and XBWINAPI_VARPROD to indicate a change or changes to the variable list. If there are changes to both, two or more messages will be sent, each of which should be decoded via separate gbatch_procmon calls.

To cancel monitoring, invoke the routine

 gbatch_unsetmon(fd)

If no monitoring is in progress, or the descriptor is invalid, this call is just ignored.


RETURN VALUES

The function gbatch_jobmon() returns 0 if successful otherwise the error code XBAPI_INVALID_FD if the file descriptor is invalid. Invalid fn parameters will not be detected and the application program will probably crash.


EXAMPLE

 void note_mod(const int fd)  {
     job_changes++;
 }
 . . .
 gbatch_jobmon(fd, note_mod);
 . . .
 if (job_changes) { /* handle changes */
 . . .
 }


SEE ALSO

gbatch_close(3), gbatch_open(3), gbatch_varmon(3).


COPYRIGHT

Copyright (c) 2009 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law.


AUTHOR

John M Collins, Xi Software Ltd.