comparison tests/sigpipe.c @ 1231:3f6adebda25c

[xemacs-hg @ 2003-01-23 11:24:08 by stephent] sigpipe <87u1g0ktd8.fsf@tleepslib.sk.tsukuba.ac.jp> test-harness.el <87ptqoktab.fsf@tleepslib.sk.tsukuba.ac.jp>
author stephent
date Thu, 23 Jan 2003 11:24:13 +0000
parents
children 679041362cd4
comparison
equal deleted inserted replaced
1230:78781398fc4c 1231:3f6adebda25c
1 /* code is all from loser.c and loser.el by Mly
2
3 Copyright (C) 2002 Richard Mlynarik <mly@pobox.com>
4
5 This is part of XEmacs
6
7 Compile this file. Run it in the background giving it a command line
8 argument PORT which is a positive integer 1024 < PORT < 32768 (avoid the
9 numbers assigned in /etc/services).
10
11 Then start up a fresh (you're going to crash) XEmacs. Execute the following
12
13 (defun lose (port)
14 (interactive "nUrk: ")
15 (require 'comint)
16 (while t
17 (condition-case e
18 (let* ((name "*lose*")
19 (b (get-buffer-create name)))
20 (switch-to-buffer b)
21 (comint-mode)
22 (comint-exec b name (cons "127.0.0.1" port) nil '())
23 (process-send-string (get-buffer-process b) "\377\373\001")
24 (process-send-string (get-buffer-process b) "\377\373\001"))
25 (error (message "URK: %s" e)) (sit-for 1))))
26
27 Then M-x lose RET PORT RET and you lose big (in XEmacs 21.1, anyway).
28 Note: the error messages are proper functioning. What should eventually
29 happen after a number of SIGPIPEs is that you get a SIGSEGV and life is
30 bad and XEmacs is dead.
31 */
32
33 #include <arpa/inet.h>
34
35 int
36 main (int argc, char **argv)
37 {
38 struct sockaddr_in junk;
39 int s;
40
41 memset (&junk, 0, sizeof (junk));
42
43 junk.sin_family = AF_INET;
44 junk.sin_addr.s_addr = htonl (INADDR_ANY); /* un*x sucks */
45 junk.sin_port = htons (atoi (argv[1])); /* un*x blows */
46
47 s = socket (PF_INET, SOCK_STREAM, 0);
48
49 bind (s, (struct sockaddr *)&junk, sizeof (junk));
50
51 listen (s, 1);
52
53 for (;;)
54 {
55 int loser = accept (s, NULL, 0);
56 close (loser);
57 }
58 }
59