Mercurial > cpython-lru_cache-weakref
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 |
| rev | line source |
|---|---|
| 862 | 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 | 4 |
| 5 All Rights Reserved | |
| 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 | 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 | 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 | 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 | 29 |
| 30 ******************************************************************/ | |
| 31 | |
| 32 /* SGI module -- random SGI-specific things */ | |
| 33 | |
| 34 #include "allobjects.h" | |
| 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 | 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 | 44 static object * |
| 45 sgi_nap(self, args) | |
| 46 object *self; | |
| 47 object *args; | |
| 48 { | |
| 49 long ticks; | |
| 50 if (!getargs(args, "l", &ticks)) | |
| 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 | 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 | 55 INCREF(None); |
| 56 return None; | |
| 57 } | |
| 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 | 82 static struct methodlist sgi_methods[] = { |
| 83 {"nap", sgi_nap}, | |
|
1878
27d4f1f9346c
Added _getpty interface.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
84 {"_getpty", sgi__getpty}, |
| 862 | 85 {NULL, NULL} /* sentinel */ |
| 86 }; | |
| 87 | |
| 88 | |
| 89 void | |
| 90 initsgi() | |
| 91 { | |
| 92 initmodule("sgi", sgi_methods); | |
| 93 } | |
| 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 */ |
