signal catching in PeeWeeLinux - sample

Dr Jaime V. Miro [email protected]
Wed, 08 Nov 2000 16:34:11 +0000


Hi Adi,
 
> Do you have a sample application to 'play' with? Then I can see if I can
> recreate your problem...
 

This is a very simple sample which shows the same behavious as my complete application with regards to signals. As before, it runs fine from my 2 development machines (both RH6.1, kernel 2.2.12-20, gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release). I can run the application from the shell and it behaves by finishing fine. However, it consistenly hangs up on PWL, just like my applcation does.


*********** main.cc ****************

#include <iostream.h>
#include <signal.h>
#include <pthread.h>

int main (int argc, char *argv[]) 
{
	sigset_t sigs_to_catch;
	int caught;

	cout << "<Main()> started.\n";
	
	// All subsequent threads will block SIGQUIT (Ctrl+\) signal (i.e., signal is marked pending, 
	// hence signal is not delivered to thead until it is unblocked (which it is with sigwait)) 
    	sigemptyset(&sigs_to_catch);
    	sigaddset(&sigs_to_catch, SIGQUIT);
	
	// this is here just because I use it in all the thread creted by my application. 
	//Not relevant here since there are no further threads, but I left it just in case it makes any difference
    	pthread_sigmask(SIG_BLOCK, &sigs_to_catch, NULL);
	
	// Wait to catch (unblock) next SIGQUIT (Ctrl+\) signal sent by user to terminate program
	sigwait(&sigs_to_catch, &caught);
	
	// End program	
	cout << "<Main()> finished\n"; 
	return 0; 

}
********** end of main.cc ********* 


Only very few lines of the Makefile are relevant here, but I include the full-blown-up thing just in case



******** Makefile *********

# This file was automatically generated by makemake.
# Do not edit it directly!
# Any changes you make will be silently overwritten.

# Edit this file to define constants and custom build targets.
# Please refer to the makemake documentation for more information.

# Useful directories

MYCODEDIR := .

# Directories to search for header files

SEARCHDIRS := -I- -I${MYCODEDIR}

# makemake variables

LINKER       := g++  
DEPENDFLAGS  := -g -D_REENTRANT -D_THREADSAFE ${SEARCHDIRS} # -Wall -Werror
TOUCHHEADERS := ${MYCODEDIR}/*.h

# make variables

CC        := gcc
CXX       := g++
CCC       := g++
FC        := f77
CFLAGS     = ${DEPENDFLAGS}
CXXFLAGS   = ${DEPENDFLAGS}
FFLAGS     = 
CPPFLAGS   = 
LOADLIBES := -ldl -lpthread -lm  
LDFLAGS   := -static  


# This is what makemake added


# linuxtop			<---------------------- name of application

linuxtop : ./wtop.o
	${LINKER} ${LDFLAGS} -o $@ ${filter-out %.a %.so, $^} ${LOADLIBES}

# target for making everything

.PHONY : all
all: linuxtop


# target for removing all object files

.PHONY : tidy
tidy::
	@${RM} core ./wtop.o

# target for removing all object files

.PHONY : clean
clean:: tidy
	@${RM} linuxtop

# list of all source files

MM_ALL_SOURCES := ./wtop.cc


# target for checking a source file

CHECKSYNTAXFILE := ${basename ${filter %${CHECKSTRING}, ${MM_ALL_SOURCES}}}

.PHONY : checksyntax
checksyntax:
  ifneq (${CHECKSYNTAXFILE},)
	@${MAKE} ${addsuffix .o, ${CHECKSYNTAXFILE}}
  else
	@echo No target to make ${CHECKSTRING}
  endif


# target for touching appropriate source files

.PHONY : touch
touch::
	@list=$$(grep -l ${TOUCHSTRING} ${MM_ALL_SOURCES}); \
     for file in $$list; do { echo $$file; touch $$file; } done


# target for calculating dependencies (MAKEMAKE)

.PHONY : jdepend
jdepend:
	@${MAKEMAKE} --depend Makefile -- ${DEPENDFLAGS} --  ./wtop.cc ./wtop.o


# DO NOT DELETE THIS LINE -- makemake depends on it.

./wtop.o: /usr/include/pthread.h /usr/include/signal.h

************* end of Makefile **********


Thanks very much for your time,

Jaime


-- 
Dr Jaime V. Miro
Sw and control systems analyst
H2eye Ltd
24-28 Hatton Wall
London EC1N 8JH

Tel:020-7404 9600
Fax:020-7404 9490
[email protected]

---------------------------------------------------
See the list archives at http://adis.on.ca/archives/
See the PWL homepage at  http://peeweelinux.com
---------------------------------------------------