annotate Modules/sgimodule.c @ 4566:6403c94de50d legacy-trunk

Added safeguard against failure in __del__.
author Guido van Rossum <guido@python.org>
date Wed, 27 Nov 1996 19:39:58 +0000
parents 65d2d8e67da3
children 68b28b8ca077
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 /***********************************************************
2061
172ba04a5191 Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents: 1878
diff changeset
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
172ba04a5191 Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents: 1878
diff changeset
3 The Netherlands.
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 All Rights Reserved
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
6
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
7 Permission to use, copy, modify, and distribute this software and its
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
8 documentation for any purpose and without fee is hereby granted,
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 provided that the above copyright notice appear in all copies and that
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
10 both that copyright notice and this permission notice appear in
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 supporting documentation, and that the names of Stichting Mathematisch
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
12 Centrum or CWI or Corporation for National Research Initiatives or
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
13 CNRI not be used in advertising or publicity pertaining to
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
14 distribution of the software without specific, written prior
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
15 permission.
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
16
4503
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
17 While CWI is the initial source for this software, a modified version
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
18 is made available by the Corporation for National Research Initiatives
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
19 (CNRI) at the Internet address ftp://ftp.python.org.
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
20
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
65d2d8e67da3 New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents: 3196
diff changeset
28 PERFORMANCE OF THIS SOFTWARE.
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
29
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 ******************************************************************/
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
31
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 /* SGI module -- random SGI-specific things */
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
33
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 #include "allobjects.h"
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 #include "modsupport.h"
947
260d96db112f Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents: 862
diff changeset
36 #include "ceval.h"
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
37
1878
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
38 #include <errno.h>
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
39 #include <sys/types.h>
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
40 #include <sys/stat.h>
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
41 #include <unistd.h>
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
42 #include <fcntl.h>
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
43
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 static object *
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 sgi_nap(self, args)
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 object *self;
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 object *args;
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 {
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 long ticks;
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 if (!getargs(args, "l", &ticks))
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 return NULL;
947
260d96db112f Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents: 862
diff changeset
52 BGN_SAVE
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 sginap(ticks);
947
260d96db112f Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents: 862
diff changeset
54 END_SAVE
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 INCREF(None);
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
56 return None;
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 }
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
58
1878
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
59 extern char *_getpty(int *, int, mode_t, int);
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
60
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
61 static object *
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
62 sgi__getpty(self, args)
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
63 object *self;
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
64 object *args;
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
65 {
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
66 int oflag;
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
67 int mode;
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
68 int nofork;
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
69 char *name;
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
70 int fildes;
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
71 if (!getargs(args, "(iii)", &oflag, &mode, &nofork))
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
72 return NULL;
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
73 errno = 0;
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
74 name = _getpty(&fildes, oflag, (mode_t)mode, nofork);
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
75 if (name == NULL) {
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
76 err_errno(IOError);
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
77 return NULL;
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
78 }
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
79 return mkvalue("(si)", name, fildes);
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
80 }
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
81
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
82 static struct methodlist sgi_methods[] = {
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
83 {"nap", sgi_nap},
1878
27d4f1f9346c Added _getpty interface.
Guido van Rossum <guido@python.org>
parents: 1746
diff changeset
84 {"_getpty", sgi__getpty},
862
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
85 {NULL, NULL} /* sentinel */
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
86 };
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
87
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
88
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
89 void
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
90 initsgi()
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
91 {
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
92 initmodule("sgi", sgi_methods);
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
93 }
bcf02052e909 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
94
1313
6ee380349c84 * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents: 1257
diff changeset
95 static int dummy; /* $%#@!& dl wants at least a byte of bss */