aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralfredoport <doyenatccny@gmail.com>2008-12-06 15:40:10 +0000
committeralfredoport <doyenatccny@gmail.com>2008-12-06 15:40:10 +0000
commitdec92cd40550e8532d36502dd75d6f9d639d7f7c (patch)
treeb4519974fc09e7b5803d3cfe149c4310cf25ffa9
parentdd55b5ac1701d057ec49a45bfbc790f628757b52 (diff)
downloadopen-axiom-dec92cd40550e8532d36502dd75d6f9d639d7f7c.tar.gz
Support getting process id in Windows.
-rw-r--r--src/ChangeLog10
-rw-r--r--src/clef/edible.c4
-rw-r--r--src/include/cfuns.h1
-rw-r--r--src/lib/cfuns-c.c10
-rw-r--r--src/lib/fnct_key.c2
-rw-r--r--src/lib/sockio-c.c8
-rw-r--r--src/lib/util.c2
7 files changed, 28 insertions, 9 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 6009a26e..8dacf4d6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,13 @@
+2008-12-06 Alfredo Portes <doyenatccny@gmail.com>
+
+ * lib/cfuns-c.c (oa_getpid): New function to
+ support getting process id in Windows.
+ * include/cfuns.h: Define it.
+ * lib/fnct_key.c: Use it.
+ * lib/sockio-c.c: Likewise.
+ * lib/util.c: Likewise.
+ * clef/edible.c: Likewise.
+
2008-12-05 Gabriel Dos Reis <gdr@cs.tamu.edu>
* algebra/fs2ups.spad.pamphlet
diff --git a/src/clef/edible.c b/src/clef/edible.c
index 0e7b9756..204c8312 100644
--- a/src/clef/edible.c
+++ b/src/clef/edible.c
@@ -155,7 +155,7 @@ main(int argc, char *argv[])
skim_wct();
#ifdef log
- sprintf(logpath, "/tmp/cleflog%d", getpid());
+ sprintf(logpath, "/tmp/cleflog%d", oa_getpid());
logfd = open(logpath, O_CREAT | O_RDWR, 0666);
#endif
@@ -479,7 +479,7 @@ void
catch_signals(void)
{
#ifdef siglog
- sprintf(sigbuff, "/tmp/csig%d", getpid());
+ sprintf(sigbuff, "/tmp/csig%d", oa_getpid());
sigfile = open(sigbuff, O_RDWR | O_TRUNC | O_CREAT);
write(sigfile, "Started \n", strlen("Started \n"));
close(sigfile);
diff --git a/src/include/cfuns.h b/src/include/cfuns.h
index 932c6d2c..99929a69 100644
--- a/src/include/cfuns.h
+++ b/src/include/cfuns.h
@@ -55,6 +55,7 @@ OPENAXIOM_EXPORT int oa_rename(const char*, const char*);
OPENAXIOM_EXPORT int oa_mkdir(const char*);
OPENAXIOM_EXPORT int oa_system(const char*);
OPENAXIOM_EXPORT char* oa_getenv(const char*);
+OPENAXIOM_EXPORT int oa_getpid(void);
OPENAXIOM_EXPORT char* oa_getcwd(void);
OPENAXIOM_EXPORT int oa_access_file_for_read(const char*);
OPENAXIOM_EXPORT char* oa_dirname(const char*);
diff --git a/src/lib/cfuns-c.c b/src/lib/cfuns-c.c
index bf3b7f7c..fb043c9f 100644
--- a/src/lib/cfuns-c.c
+++ b/src/lib/cfuns-c.c
@@ -505,7 +505,15 @@ oa_system(const char* cmd)
return system(cmd);
}
-
+OPENAXIOM_EXPORT int
+oa_getpid(void)
+{
+#ifdef __WIN32__
+ return GetCurrentProcessId();
+#else
+ return getpid();
+#endif
+}
/* Return the value of an environment variable. */
OPENAXIOM_EXPORT char*
diff --git a/src/lib/fnct_key.c b/src/lib/fnct_key.c
index f2c088ea..b125fbca 100644
--- a/src/lib/fnct_key.c
+++ b/src/lib/fnct_key.c
@@ -80,7 +80,7 @@ set_editor_key(void)
{
int pid;
- sprintf(editorfilename, "/tmp/clef%d", pid = getpid());
+ sprintf(editorfilename, "/tmp/clef%d", pid = oa_getpid());
if (function_key[12].str == NULL) {
(function_key[12]).type = SPECIAL;
diff --git a/src/lib/sockio-c.c b/src/lib/sockio-c.c
index 077f45fb..365e88eb 100644
--- a/src/lib/sockio-c.c
+++ b/src/lib/sockio-c.c
@@ -1014,7 +1014,7 @@ connect_to_local_server_new(char *server_name, int purpose, int time_out)
return NULL;
}
- send_int(sock, getpid());
+ send_int(sock, oa_getpid());
send_int(sock, purpose);
send_int(sock, sock->socket);
sock->pid = get_int(sock);
@@ -1066,7 +1066,7 @@ connect_to_local_server(char *server_name, int purpose, int time_out)
if (code == -1) {
return NULL;
}
- send_int(sock, getpid());
+ send_int(sock, oa_getpid());
send_int(sock, sock->purpose);
send_int(sock, sock->socket);
sock->pid = get_int(sock);
@@ -1124,7 +1124,7 @@ init_purpose_table(void)
OPENAXIOM_EXPORT int
make_server_number(void)
{
- spad_server_number = getpid();
+ spad_server_number = oa_getpid();
return spad_server_number;
}
@@ -1249,7 +1249,7 @@ get_socket_type(openaxiom_sio *sock)
sock->pid = get_int(sock);
sock->purpose = get_int(sock);
sock->remote = get_int(sock);
- send_int(sock, getpid());
+ send_int(sock, oa_getpid());
send_int(sock, sock->socket);
purpose_table[sock->purpose] = sock;
switch (sock->purpose) {
diff --git a/src/lib/util.c b/src/lib/util.c
index 8174fa8c..b4946858 100644
--- a/src/lib/util.c
+++ b/src/lib/util.c
@@ -58,7 +58,7 @@ checker(int code, int lineNumber, char *errorStr)
if (code < 0) {
fprintf(stderr, "Error occured during %s\n", errorStr);
fprintf(stderr, "Error code of %d\n", errno);
- fprintf(stderr, "Error in line number %d of process %d\n", lineNumber, getpid());
+ fprintf(stderr, "Error in line number %d of process %d\n", lineNumber, oa_getpid());
perror("");
}
return (code);