Mercurial > emacs
annotate lib-src/ntlib.c @ 14911:f736e9cb067e libc-960329 libc-960330 libc-960331 libc-960401 libc-960402 libc-960403 libc-960404 libc-960405 libc-960406 libc-960407 libc-960408
(aux): Delete another duplicate entry.
| author | Doug Evans <dje@gnu.org> |
|---|---|
| date | Fri, 29 Mar 1996 01:49:55 +0000 |
| parents | 730a5bd19776 |
| children | 92326afec2a6 |
| rev | line source |
|---|---|
| 9803 | 1 /* Utility and Unix shadow routines for GNU Emacs support programs on NT. |
| 2 Copyright (C) 1994 Free Software Foundation, Inc. | |
| 3 | |
|
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
9803
diff
changeset
|
4 This file is part of GNU Emacs. |
| 9803 | 5 |
|
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
9803
diff
changeset
|
6 GNU Emacs is free software; you can redistribute it and/or modify |
|
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
9803
diff
changeset
|
7 it under the terms of the GNU General Public License as published by |
|
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
9803
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
|
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
9803
diff
changeset
|
9 any later version. |
| 9803 | 10 |
|
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
9803
diff
changeset
|
11 GNU Emacs is distributed in the hope that it will be useful, |
|
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
9803
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
9803
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
9803
diff
changeset
|
14 GNU General Public License for more details. |
| 9803 | 15 |
|
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
9803
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
|
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
9803
diff
changeset
|
17 along with GNU Emacs; see the file COPYING. If not, write to |
|
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
9803
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
|
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
9803
diff
changeset
|
19 Boston, MA 02111-1307, USA. |
| 9803 | 20 |
| 21 Geoff Voelker (voelker@cs.washington.edu) 10-8-94 | |
| 22 */ | |
| 23 | |
| 24 #include <windows.h> | |
| 25 #include <stdlib.h> | |
| 26 #include <stdio.h> | |
| 27 | |
| 28 #define MAXPATHLEN _MAX_PATH | |
| 29 | |
| 30 /* Emulate sleep...we could have done this with a define, but that | |
| 31 would necessitate including windows.h in the files that used it. | |
| 32 This is much easier. */ | |
| 33 void | |
| 34 nt_sleep(int seconds) | |
| 35 { | |
| 36 Sleep (seconds * 1000); | |
| 37 } | |
| 38 | |
| 39 /* Get the current working directory. */ | |
| 40 int | |
| 41 getwd (char *dir) | |
| 42 { | |
| 43 return GetCurrentDirectory (MAXPATHLEN, dir); | |
| 44 } | |
| 45 | |
|
14837
730a5bd19776
(getpid): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
46 int |
|
730a5bd19776
(getpid): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
47 getpid () |
|
730a5bd19776
(getpid): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
48 { |
|
730a5bd19776
(getpid): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
49 return _getpid (); |
|
730a5bd19776
(getpid): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
50 } |
|
730a5bd19776
(getpid): New function.
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
51 |
| 9803 | 52 static HANDLE getppid_parent; |
| 53 static int getppid_ppid; | |
| 54 | |
| 55 int | |
| 56 getppid(void) | |
| 57 { | |
| 58 char *ppid; | |
| 59 DWORD result; | |
| 60 | |
| 61 ppid = getenv ("__PARENT_PROCESS_ID"); | |
| 62 if (!ppid) | |
| 63 { | |
| 64 printf("no pid.\n"); | |
| 65 return 0; | |
| 66 } | |
| 67 else | |
| 68 { | |
| 69 getppid_ppid = atoi (ppid); | |
| 70 } | |
| 71 | |
| 72 if (!getppid_parent) | |
| 73 { | |
| 74 getppid_parent = OpenProcess (SYNCHRONIZE, FALSE, atoi(ppid)); | |
| 75 if (!getppid_parent) | |
| 76 { | |
| 77 printf ("Failed to open handle to parent process: %d\n", | |
| 78 GetLastError()); | |
| 79 exit (1); | |
| 80 } | |
| 81 } | |
| 82 | |
| 83 result = WaitForSingleObject (getppid_parent, 0); | |
| 84 switch (result) | |
| 85 { | |
| 86 case WAIT_TIMEOUT: | |
| 87 /* The parent is still alive. */ | |
| 88 return getppid_ppid; | |
| 89 case WAIT_OBJECT_0: | |
| 90 /* The parent is gone. Return the pid of Unix init (1). */ | |
| 91 return 1; | |
| 92 case WAIT_FAILED: | |
| 93 default: | |
| 94 printf ("Checking parent status failed: %d\n", GetLastError()); | |
| 95 exit (1); | |
| 96 } | |
| 97 } |
