gmon.out always appears

Hello.

I have one X-file :frowning:

Every time I run an application I’m programming, a file called gmon.out appears… Now I know that it’s quite useful and I’ve used it to improve the performance of my code… but now I’m tired. I WANT TO GET RID OF IT! :laughing:

In my Makefile there is nothing related to compile with profiling…

UNAME	:= $(shell uname)
DEBUG	:= yes

EXEC	= balance
SRCS	= error.c sockhelp.c server.c gyro.c servo.c main.c
CFLAGS	= -O3 -Wall -pedantic
LDFLAGS	= -lm -ldscud5

OBJS	= $(SRCS:.c=.o) 

# Compiling in Linux
ifeq ($(UNAME), Linux)
LDFLAGS	+= -I/usr/local/dscud5 -L/usr/local/dscud5 -lpthread
endif

# Compiling in QNX
ifeq ($(UNAME), QNX)
CFLAGS	+= -DQNX
LDFLAGS	+= -I/opt/dscud5 -L/opt/dscud5 -lsocket
endif

# Compiling with debug
ifeq ($(DEBUG), yes)
CFLAGS	+= -DDEBUG
endif

all	: $(EXEC)

$(EXEC)	: $(OBJS)

	$(LINK.c) -o $@ $^ $(LDFLAGS)

clean:
	 rm -f $(EXEC) $(OBJS)

I’ve tried in two QNX 6.3.0 machines and the same result: gmon.out appears. So, it seems it’s nothing related with any option I could have enabled without noticing…

The only “suspicious” thing is that I have a SIGINT handler that cancels the threads, closing the file descriptors and exits.

	struct sigaction sa;			/* To handle SIGINT */
	/* Programme new handlers for SIGINT */
	/* Trap SIGINT (Ctrl + C) Signal */
	sa.sa_handler = sigint_handler;		/* Handler for SIGINT */
	sa.sa_flags = 0;			/* No special flags */
	sigaction(SIGINT, &sa, NULL);		/* New action for SIGINT */

[...]

void sigint_handler(int sig)
{
	/* Cancel the launched threads */
	if (inputClientID > 0)
		if (pthread_cancel(inputClientID) < 0)
			err_quit("pthread_cancel inputClientID");
	if (waitForInputsID > 0)
		if (pthread_cancel(waitForInputsID) < 0)
			err_quit("pthread_cancel waitForInputsID");
	if (runServosID > 0)
		if (pthread_cancel(runServosID) < 0)
			err_quit("pthread_cancel runServosID");

	DBGP("\nCtrl + C trapped\n");
	exit(EXIT_SUCCESS);
}

In another project I have practically the same Makefile and it doesn’t throw that gmon.out. I doesn’t handle SIGINT either.

Any hint???

Thanks in advance,

Dario

Is it possible the dscud5 library is compile with profiling on.

Mario, maybe!! ;)

How can I know it?

If that library is yours then you should be able to check in the Makefile. If it’s not, I guess objdump could provide some clue.