This question is complicated by the fact that there are multiple implementations of MSGBOX.SBX.
Originally there was an external MSGBOX.SBX (source included in [907,20] of the SOSLIB), but somewhere in the middle of the 5.0 development cycle we folded it into the ashell executable). However, at the same time, it was made to detect whether you had an AUI support (i.e. A-Shell graphic support via A-Shell/Windows or ATE) and if so, it transfers the request to the client which displays a regular Windows message box. Adding a timer to that would be nice, and something I've had on my to-do list, but it requires some low-level finagling and would require updating the A-Shell and ATE executables.
In 5.0.984.1, MSGBOX began to detect true background job status (job launched in
Quiet Mode , or uses piped input or otherwise doesn't have a real terminal device attached), and in that case just logs the message to the ashlog.log file and continues as if the user had responded with YES (when YES is an option), or ABORT (if the choice is Abort/Retry/Ignore), or CANCEL (for Retry/Cancel), else OK. I'm not sure why you're not getting that effect. Perhaps you aren't really using XCALL MSGBOX? Or are on a version prior to 5.0.984.1? Or your "background" jobs don't meet the test we are using for "background"? Assuming it's the latter, and you're getting a message box that looks something like this...
...then it would be quite simple to change the implementation. The recommended procedure would as as follows:
1. Add an ALIAS to the miame.ini so that XCALL MSGBOX gets redirected to a different subroutine name (i.e. don't use the internal MSGBOX.SBR):
ALIAS=MSGBOX:MSGBX2
2. Create a MSGBX2.SBX in Basic which implements the same parameter list/interface as the existing MSGBOX. You can use the existing MSGBOX.BP mentioned above as a starting point. For convenience, I've uploaded a copy with a 30 second timeout already implemented (see note [110] for the single-line patch):
MSGBOX.BP (source to MSGBOX.SBX) *
TSTMSG.BP (test program) * You'd need to rename the MSGBOX.SBX to MSGBX2.SBX (or whatever you choose to use in the ALIAS statement).
Another approach (instead of a timeout) would be to detect that the job is running in background and just log the message instead of doing the XCALL MSGBOX. This would short-circuit whatever the issue is that is preventing the built-in MSGBOX from detecting that you are in background. Typical techniques for detecting background status are:
a) Use
XCALL GETUSN to see if the
machine$ is a real terminal device or a background device.
b) Use
XCALL GETJOB to look at the job name. (In the default naming scheme, background job names start with TAS while foreground jobs start with TSK, but you may also use the
-j jobname command line switch to assign specific names to specific background tasks, which makes them easier to spot in the SYSTAT.)
c) If your "background" jobs belong to a limited set of programs that are always run in that mode, you can key off the program name (also returned by GETJOB.SBR).