<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: C : Using signals with the libpthread library in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/c-using-signals-with-the-libpthread-library/m-p/2661804#M721741</link>
    <description>Hello Rick,&lt;BR /&gt;Did you finally find a solution to your problem concerning SIGALRM signal handler when you link your program with libpthread library, or did you have to look for an alternate way to do what you wanted to do ?&lt;BR /&gt;I'm having the exact same problem (messages posted on last tuesday and wednesday), but so far could not find anybody to help and am still trying to solve it.&lt;BR /&gt;Hope you get this message. Thank you in advance.&lt;BR /&gt;Regards</description>
    <pubDate>Thu, 16 May 2002 08:32:48 GMT</pubDate>
    <dc:creator>see call 1201019986</dc:creator>
    <dc:date>2002-05-16T08:32:48Z</dc:date>
    <item>
      <title>C : Using signals with the libpthread library</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-using-signals-with-the-libpthread-library/m-p/2661802#M721739</link>
      <description>Hi, I have run into a problem when porting our application. The app is using a combination of signals and the sleep() system call. We recently had to add the libpthread to the list of libraries to link with, due to upgrading the product (ZCOM) that we are linking to, and this changed the behavior of the application. Here is an explanation. The app sets up a function to call in the sigaction for the SIGALRM signal.&lt;BR /&gt;in the code, some logic requires the alarm() call to be invoked, to wake up the process during a sleep() function. The SIGALRM signal handler sets a variable to 1. Below is a trimmed down example.&lt;BR /&gt;&lt;BR /&gt;/* start of x.c */&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;SIGNAL.H&gt;&lt;BR /&gt;int got_it = 0;&lt;BR /&gt;&lt;BR /&gt;void H_alarm()&lt;BR /&gt;{ &lt;BR /&gt;  got_it = 1;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;  struct sigaction act;&lt;BR /&gt;  act.sa_flags = 0;&lt;BR /&gt;  act.sa_handler = H_alarm;  &lt;BR /&gt;  sigaction(SIGALRM, &amp;amp;act, NULL);&lt;BR /&gt;&lt;BR /&gt;  alarm(5);&lt;BR /&gt;  sleep(10);&lt;BR /&gt;  if (got_it) {&lt;BR /&gt;     printf("WENT INTO ALARM HANDLER\n");&lt;BR /&gt;  } else {&lt;BR /&gt;     printf("DID NOT GO INTO ALARM HANDLER\n");&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;/* end of x.c */&lt;BR /&gt;&lt;BR /&gt;Two options...&lt;BR /&gt;1) cc -o x x.c &lt;BR /&gt;2) cc -o x x.c -lpthread&lt;BR /&gt;&lt;BR /&gt;If linked without libpthread.a,&lt;BR /&gt;the response is WENT INTO ALARM HANDLER, after&lt;BR /&gt;the 5 seconds. If linked WITH libpthread.a,&lt;BR /&gt;the process still ends after 5 seconds, but it does not invoke the handler, and will print the second statement.&lt;BR /&gt;&lt;BR /&gt;There are probably other ways to re-design the app, but it is a large app, and I would prefer if someone knew if there was a different compilation option, or additional value to set which would force the behavior to be the same as it is w/o linking to pthread. &lt;BR /&gt;&lt;BR /&gt;Can anyone help? Thanks in advance!!&lt;BR /&gt;&lt;/SIGNAL.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Sat, 09 Feb 2002 02:22:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-using-signals-with-the-libpthread-library/m-p/2661802#M721739</guid>
      <dc:creator>Rick Barlow</dc:creator>
      <dc:date>2002-02-09T02:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: C : Using signals with the libpthread library</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-using-signals-with-the-libpthread-library/m-p/2661803#M721740</link>
      <description>Hi Rick,&lt;BR /&gt;&lt;BR /&gt;sleep() behaves differently in a multi-threaded environment.  From the sleep manpage:&lt;BR /&gt;&lt;BR /&gt;If a SIGALRM is generated for a multi-threaded process, it may not be delivered to a thread currently in sleep().&lt;BR /&gt;&lt;BR /&gt;I am not familiar with your application that uses sleeps and alarms, but you could use sigwait() to block your program until it receives a SIGALRM.&lt;BR /&gt;&lt;BR /&gt;Hope that helps,&lt;BR /&gt;Jason</description>
      <pubDate>Tue, 12 Feb 2002 18:29:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-using-signals-with-the-libpthread-library/m-p/2661803#M721740</guid>
      <dc:creator>Jason Deckard</dc:creator>
      <dc:date>2002-02-12T18:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: C : Using signals with the libpthread library</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/c-using-signals-with-the-libpthread-library/m-p/2661804#M721741</link>
      <description>Hello Rick,&lt;BR /&gt;Did you finally find a solution to your problem concerning SIGALRM signal handler when you link your program with libpthread library, or did you have to look for an alternate way to do what you wanted to do ?&lt;BR /&gt;I'm having the exact same problem (messages posted on last tuesday and wednesday), but so far could not find anybody to help and am still trying to solve it.&lt;BR /&gt;Hope you get this message. Thank you in advance.&lt;BR /&gt;Regards</description>
      <pubDate>Thu, 16 May 2002 08:32:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/c-using-signals-with-the-libpthread-library/m-p/2661804#M721741</guid>
      <dc:creator>see call 1201019986</dc:creator>
      <dc:date>2002-05-16T08:32:48Z</dc:date>
    </item>
  </channel>
</rss>

