如何在 RPG 中创建警报和信号处理程序? (AS400 iSeries v5r4)

发布于 2024-09-15 11:22:50 字数 470 浏览 17 评论 0原文

一个有价值的答案将包括执行类似操作的角色扮演代码,

volatile bool interrupted;
main() {
  sigaction(SIG_ALARM, myhandler) // register handler
  alarm(3) // set the alarm
  sleep(5) // blocking call, sleep just as an example.
  alarm(0) // disable the alarm
}
myHandler() {
  interrupted=true
}

我认为您已经明白了。 我有一个阻塞的代码,类似于睡眠,我想要一个警报来解锁阻塞调用

另一个问题,警报处理程序完成后,执行点去哪里?它会终止程序吗?我可以在 myHandler() 内部调用另一个方法吗?是否允许,在程序完成之前我怎样才能继续做某事,比如记录到表直到我去了哪里?

非常感谢 !

A valuable answer will include the rpg code that does something like this

volatile bool interrupted;
main() {
  sigaction(SIG_ALARM, myhandler) // register handler
  alarm(3) // set the alarm
  sleep(5) // blocking call, sleep just as an example.
  alarm(0) // disable the alarm
}
myHandler() {
  interrupted=true
}

I think you've got the idea.
I have a code that blocks, similar to sleep, and I want an alarm to unlock the blocking call

Another question, after the alarm handler has finished, where does the execution point goes ? does it terminate the program ?, can I call another method while inside myHandler() ? Is it allowed, how can I keep doing something before the program finishes, like log to a table till where did I went ?

Thank you very much !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吝吻 2024-09-22 11:22:50

本文提供了一些使用 ILE RPG 信号(包括 SIG_ALARM)的好示例:
http://systeminetwork.com/article/terminate-and-stay-residentin- rpg

如果您的程序在收到 SIG_ALARM 时正在运行,则执行会暂时切换到警报处理程序。警报处理程序完成后,将从中断处恢复执行。

链接中给出的示例执行来自警报处理程序的 QCMDEXC 和文件 IO,因此您似乎可以在那里执行任何操作。 (不过,他的示例基本上没有可能受到干扰的主线运行;事实上,他的警报处理程序在主线结束后正在运行!)

This article gives some good examples of using signals (including SIG_ALARM) from ILE RPG:
http://systeminetwork.com/article/terminate-and-stay-residentin-rpg

If your program is running while SIG_ALARM is received, execution temporarily switches to the alarm handler. After the alarm handler is finished, execution resumes where it left off.

The example given in the link does QCMDEXC and file IO from the alarm handler, so it would seem like you can do just about anything there. (Though, his example had basically no mainline running that could be interfered with; in fact his alarm handler was running after the mainline ended!)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文