pastebin - collaborative debugging tool
eckelmann.kpaste.net RSS

Difference between
modified post 8ad53a3 by Anonymous on Fri 22nd Feb 2019 15:44
original post 92b6 by Anonymous on Thu 17th Jan 2019 08:44
Download diff
Show old version | new version | both versions

    
11
#include <pthread.h>
22
#include <stdio.h>
33
#include <stdlib.h>
44
#include <unistd.h>
55
#include <signal.h>
66
#include <errno.h>
88
/* Simple error handling functions */
1010
#define handle_error_en(en, msg) \
1111
	do { errno = en; perror(msg); exit(EXIT_FAILURE); } while (0)
1414
int main(int ac, char *av[])
1515
{
1616
	sigset_t set;
1717
	int i;
1818
	char buff[512];
2020
	(void)puts("#start");
2222
	sigemptyset(&set);
2323
	sigaddset(&set, SIGRTMIN+2);
2424
	sigaddset(&set, SIGRTMIN+3);
2525
	i = pthread_sigmask(SIG_BLOCK, &set, NULL);
2626
	if (i != 0)
2727
		handle_error_en(i, "pthread_sigmask() failed");
2929
	(void)puts("#mark1");
3131
	/*
3232
	 * stupid /bin/kill in Linux cannot handle realtime signal
3333
	 * *names*, so we pass the signal number instead
3434
	 */
35-
	(void)snprintf(buff, sizeof(buff), "kill -s %d %d", SIGRTMIN+2, getpid());
35+
	(void)snprintf(buff, sizeof(buff), "kill -s %d %ld", (int)SIGRTMIN+2, (long)getpid());
36-
	(void)printf("# executing %s\n", buff);
36+
	(void)printf("# executing '%s'\n", buff);
3737
	(void)system(buff);
3939
	(void)puts("#mark2");
4141
	(void)sleep(2);
4242
	(void)puts("#mark3");
4444
	i = pthread_sigmask(SIG_UNBLOCK, &set, NULL);
4545
	if (i != 0)
4646
		handle_error_en(i, "pthread_sigmask() failed");
4848
	/*
4949
	 * unblocking the SIGRTMIN signals will trigger the default handler for
5050
	 * the SIGRT signals, which terminates the process, so we will never reach
5151
	 * this point in the program
5252
	 */
5353
	(void)puts("#notreached");
5555
	return EXIT_SUCCESS;
5656
}

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}





All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at