11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

System and Other FunctionsDeclarationint sigrtchk();PurposeChecks forasynchronous events.NotesShould be called whenever one of the followingsystem calls fails: open(), close(),read(), write(), ioctl(), pause(), any call thatfails when the process receives a signal. Itreturns a code indicating the action the usershould take:-1 = Not a signal. Check for I/O error. Seecontents of errno variable.0 = Other signal. Restart operation frompoint at which it was interrupted.1 = SIGINT/. Exit from $ZF with aSIGTERM "return 0." The System trapsthese signals appropriately.In a typical $ZF function used to control some device, you would code something like this:IF ((fd = open(DEV_NAME, DEV_MODE)) < 0) {; Set some flags; Call zferror; return 0;}The open system call can fail if the process receives a signal. Usually this situation is not anerror and the operation should be restarted. Depending on the signal, however, you mighttake other actions. So, to take account of all the possibilities, consider using the following Ccode:sigrtclr();WHILE (TRUE) {IF (sigrtchk() == 1) { return 1 or 0; }IF ((fd = open(DEV_NAME, DEV_MODE)) < 0) {switch (sigrtchk()) {case -1:/* This is probably a real device error */; Set some flagsCall zferrorreturn 0;case 0:/* A innocuous signal was received. Restart. */; continue;case 1:/* Someone is trying to terminate your job. */Do cleanup workreturn 1 or 0;}}ELSE { break; }/* Code to handle the normal situation: *//* open() system call succeeded */530 <strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!