HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Alarm Signal Issue
Operating System - HP-UX
1833726
Members
2510
Online
110063
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2004 10:23 AM
03-16-2004 10:23 AM
Good Morning:
I have a server program in cc. this Program is a socket listener. Under certain conditions I need to set the alarm (alarm(120)) in the loop in wich it is accepting conenctions. And when this signal (SIGALRM) arrives to my program, the handler signal function is executed, but the program cant not accept more connections in the listener socket. The accept function returns with error and the program crashes with errno 4.
Somebody have idea how sove this issue? Thanks a lot for your help.
I have a server program in cc. this Program is a socket listener. Under certain conditions I need to set the alarm (alarm(120)) in the loop in wich it is accepting conenctions. And when this signal (SIGALRM) arrives to my program, the handler signal function is executed, but the program cant not accept more connections in the listener socket. The accept function returns with error and the program crashes with errno 4.
Somebody have idea how sove this issue? Thanks a lot for your help.
alfonsoarias
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2004 10:33 AM
03-16-2004 10:33 AM
Solution
If I understand your question, you are doing an alarm(120) before an accept(). I assume that if accept receives a connection you issue an alarm(0) to cancel the alarm. I strongly suspect that you have no SIGALRM signal handler. Your errno 4 (EINTR) make perfect sense; a system call was terminated when the process received a signal -- in your case the SIGALRM.
Normally, you would do something like a setjmp() and your signal handler would do a longjmp() causing setjmp() to return a non-zero value and thus branch to another section of code. I'd have to see you code to help any more.
Normally, you would do something like a setjmp() and your signal handler would do a longjmp() causing setjmp() to return a non-zero value and thus branch to another section of code. I'd have to see you code to help any more.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2004 04:03 AM
03-17-2004 04:03 AM
Re: Alarm Signal Issue
It is clear that you do have a signal handler for SIGALRM since the default action without a handler would kill a process.
It is quite normal for a blocking call such as accept() to return EINTR. In general it is good practice to check for an EINTR errno and just loop back to making a call that you don't want to abandon because of a signal. You definitely should not start messing around with setjmp/longjmp for this simple activity.
You can also consider setting your signal handler to restart system calls. The sigaction() function has an SA_RESTART flag for that purpose. It will cause a call such as accept() to restart instead of returning with EINTR. You need to be careful that restarting calls will not break other assumptions that your code makes about what a signal can break out of. You might have some situations where you expect a SIGALARM to cause you to break out of a call such as select().
It is quite normal for a blocking call such as accept() to return EINTR. In general it is good practice to check for an EINTR errno and just loop back to making a call that you don't want to abandon because of a signal. You definitely should not start messing around with setjmp/longjmp for this simple activity.
You can also consider setting your signal handler to restart system calls. The sigaction() function has an SA_RESTART flag for that purpose. It will cause a call such as accept() to restart instead of returning with EINTR. You need to be careful that restarting calls will not break other assumptions that your code makes about what a signal can break out of. You might have some situations where you expect a SIGALARM to cause you to break out of a call such as select().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2004 08:59 AM
03-18-2004 08:59 AM
Re: Alarm Signal Issue
A true server would not need to do this. So maybe rethinking your architecture would be a good idea. If the program also needs to do some background work, Just create a separate thread of execution and run that work in a seperate thread.Also creating a thread to perform work, that is read from the accept is general a common practice. Check out the stevens network programming books...
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP