delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/27/19:55:34

From: Raul <e36531491 AT omega DOT uab DOT es>
Newsgroups: comp.os.msdos.djgpp
Subject: How does signals work on djgpp?
Date: Fri, 27 Mar 1998 12:25:22 +0100
Organization: Universitat Autonoma de Barcelona
Lines: 59
Distribution: inet
Message-ID: <Pine.SOL.3.95.980327121832.3637A-100000@Xi>
Reply-To: Raul <e36531491 AT omega DOT uab DOT es>
NNTP-Posting-Host: xi.uab.es
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I have made a example program for testing signals. I call alarm() and a
SIGALRM signal is suposed to be generated, but no signal y raised at all.
Why?
What does pause() do on djgpp? How can I wait for a signal?

10x.

Here is the code:

#include <stdio.h>
#include <signal.h>
#include <setjmp.h>
#include <dpmi.h>

static jmp_buf entorno;

static void sigalrm_handler (sig)
int sig;
{
  longjmp (entorno, 1);
}

void lock_my_handler (){
  _go32_dpmi_lock_code(sigalrm_handler, (unsigned long)(lock_my_handler - sigalrm_handler));
}

dormir(seg)
unsigned seg;
{
  unsigned alarma_ant;
  void (*sigalrm_handler_ant) ();

  if (seg==0) return;
  sigalrm_handler_ant=signal(SIGALRM, sigalrm_handler);
  if (setjmp(entorno)==0){
    alarma_ant = alarm (seg);
    pause ();
  } else {
    signal(SIGALRM, sigalrm_handler_ant);
    alarm(alarma_ant);
  }
}

main (){
  int i;

  lock_my_handler ();
  for (i=0;i<10;i++){
    printf ("sleeping %d seconds.\n", i );
    dormir (i);
  }
}






- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019