public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: "kumar" <kumareshind@gmx.net>
To: linux-ia64@vger.kernel.org
Subject: Re: [Linux-ia64] problem in sigtimedwait
Date: Thu, 20 Jun 2002 06:52:01 +0000	[thread overview]
Message-ID: <marc-linux-ia64-105590701905694@msgid-missing> (raw)
In-Reply-To: <marc-linux-ia64-105590701905688@msgid-missing>

[-- Attachment #1: Type: text/plain, Size: 1030 bytes --]

Hello david,
I have attached the test program as you asked for testing "sigtimedwait".
whether it returns proper "si_fd" value.
Please try with this.

I have tested by the following way:
1)Compiled and run the program
2)In the other terminal, i have run the command "telnet localhost 5001".
3)You can view the results in the terminal where the test program is
running.

Thanks in advance.
Kumar.

> >>>>> On Wed, 19 Jun 2002 16:31:30 +0530, "kumar" <kumareshind@gmx.net>
said:
>
>   Kumar> All, Do IA64 Linux release have complete support for RT
>   Kumar> Signals.  Or which version has full support for RT signals.
>
> There have not been any recent changes in this area.
>
>   Kumar> The problem we faced is that the : sigtimedwait call does not
>   Kumar> return siginfo_t's si_fd value.
>
> Do you have a minimal test program that reproduces the issue?
>
> --david
>
> _______________________________________________
> Linux-IA64 mailing list
> Linux-IA64@linuxia64.org
> http://lists.linuxia64.org/lists/listinfo/linux-ia64

[-- Attachment #2: rtsignaltest.c --]
[-- Type: application/octet-stream, Size: 3439 bytes --]


#include <stdio.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>

static sigset_t signalset;
static siginfo_t siginfo;

#define F_SETSIG 10

void setCloseOnExec(int fd) {
    int flags;
    int dummy = 0;
    if ((flags = fcntl(fd, F_GETFL, dummy)) < 0) {
	printf("FD %d: fcntl F_GETFL: %s\n", fd, strerror(errno));
	return;
    }
    if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0)
	printf("FD %d: set close-on-exec failed: %s\n", fd, strerror(errno));
}


void enable_rt_signal(int fd) {
  int flags;
  int err = 0;

  flags = fcntl(fd, F_GETFL, err);
  if (flags < 0) {
    printf("enable_realtime_signals: Error getting flags FD %d\n", fd);
    return;
  }
  err = fcntl(fd, F_SETFL, flags | O_ASYNC | O_RDWR);
  if (err < 0) { 
    printf("enable_realtime_signals: Error setting ASYNC FD %d\n", fd);
    return;
  }
  err = fcntl(fd, F_SETSIG, SIGRTMIN+10);
  if (err < 0) {
    printf("enable_realtime_signals: Error setting signum FD %d\n", fd);
    return;
  }
  err = fcntl(fd, F_SETOWN, getpid());
  if (err < 0) {
    printf("enable_realtime_signals: Error setting pid FD %d\n", fd);
    return;
  }
}


void
commSetNonBlocking(int fd)
{
    int flags;
    int dummy = 0;

    if ((flags = fcntl(fd, F_GETFL, dummy)) < 0) {
      printf("FD %d: fcntl F_GETFL: %s\n", fd, strerror(errno));
      return;
    }
    if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) {
      printf("commSetNonBlocking: FD %d: %s\n", fd, strerror(errno));
      return;
    }
}



int main() {
  int listenfd;
  int fd;
  int ret_val;
  struct sockaddr_in addr;
  short port = 5001;

  sigemptyset(&signalset);
  sigaddset(&signalset, SIGRTMIN+10);
  sigaddset(&signalset, SIGIO);
  sigprocmask(SIG_BLOCK, &signalset, NULL);

  fd = socket(AF_INET, SOCK_STREAM, 0);
  if(fd <= 0) {
    printf("Socket creation failed : %s\n",strerror(errno));
    return 1;
  }
 
  /* Set signal, pid etc */

  setCloseOnExec(fd);
  commSetNonBlocking(fd);  
  enable_rt_signal(fd);

  /* Bind to port 5001 */

  memset(&addr, '\0', sizeof(addr));
  addr.sin_family = AF_INET;
  addr.sin_port = htons(port);
  // addr.sin_addr = in_addr;
   
  ret_val = bind(fd, (struct sockaddr *)&addr, sizeof(addr));
  if(ret_val < 0) { 
    printf("Bind failed : %s\n",strerror(errno));
    return 1;
  }  

  /* Listen */
 
  ret_val = listen(fd, 5);
  if(ret_val < 0) { 
    printf("Listen failed : %s\n",strerror(errno));
    return 1;
  }
  
  printf("Listening FD is %d\n",fd);

  /* we will be here ..always */

  while(1) {
    int signum;
    struct timespec ts;
    ts.tv_sec = 2;
    ts.tv_nsec = (100 % 1000) * 1000;
    
    signum = sigtimedwait(&signalset, &siginfo, &ts);

    if(signum == -1 && errno == EINTR) {
      printf("Timeout\n");
      continue;
    }

    printf("Signum : %d : %s\n",signum,strerror(errno));

    if(signum != SIGRTMIN+10) {
      printf("Unknown signal \n");      
    }

    if(signum == SIGRTMIN+10) {
      /* Print siginfo values */
      printf("Signum : %d\n",siginfo.si_signo);
      printf("FD     : %d\n",siginfo.si_fd);
      printf("BAND   : %d\n",siginfo.si_band);
      printf("Code   : %d\n",siginfo.si_code);
    }
  }
  return 0;
}


  parent reply	other threads:[~2002-06-20  6:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-19 11:13 [Linux-ia64] problem in sigtimedwait kumar
2002-06-19 16:41 ` David Mosberger
2002-06-20  6:52 ` kumar [this message]
2002-06-23 17:15 ` Fw: " kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=marc-linux-ia64-105590701905694@msgid-missing \
    --to=kumareshind@gmx.net \
    --cc=linux-ia64@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox