There is function like that built into the system. And it was recently
discussed on this list. RPG can check for %SHTDN
http://publib.boulder.ibm.com/infocenter/iseries/v7r1m0/topic/rzasd/sc092508873.htm#bbshut
CL can check for RTVJOBA ENDSTS(&ENDSTS)
Those get activated when a *CNTRLD is done. Either via ENDJOB or ENDSBS
or even PWRDWNSYS. The problem is, let's say you have a data queue
program. You wait on the data queue for 30 seconds. If no activity you
check for %SHTDN. If no shutdown you go wait another 30 seconds. Now,
someone runs PWRDWNSYS *CNTRLD DELAY(1). %SHTDN is activated but you
won't check it until the next loop. Before that loop gets activated the
*CNTRLD automatically gets changed to *IMMED and your job goes down hard.
Event driven languages can process this differently than procedural
languages. You can try to submit a DCR or a COMMON requirement that
%SHTDN hit an interactive program waiting on a screen as if a function key
was pressed and you can check that indicator. Sounds simple and
reasonable, and wouldn't necessarily be disruptive on existing programs,
but I question whether IBM would avoid it out of hand as it has anything
to do with updating the 5250 experience. Programs that don't code for it
might pop up "invalid function key" or some such error. Maybe a 5250
environment variable about whether or not to pass %SHTDN to 5250 as an
indicator (or some such thing).
Either way, now let's look at it from a system task. You have 900
interactive programs and 35 batch programs running. Someone runs
PWRDWNSYS *CNTRLD DELAY(5). After 5 seconds it changes to *IMMED. Is
someone telling us that *CNTRLD will flush all cache? But what about all
those programs still running that won't end until it automatically changes
to *IMMED? Did it flush all cache first, and then end those programs? Is
that cool? Or, does it say, well, I know that someone requested *CNTRLD
but I had to switch to *IMMED but since they requested *CNTRLD I will
flush the cache after everything is ended? If you can find that written,
fine, show me. I still say, barring further proof, neither flushes cache
safely and you'd be better served by following the recommendations in the
hardware service manuals before replacing cache batteries, swapping out
disk drives, etc.
Rob Berendt
As an Amazon Associate we earn from qualifying purchases.