summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Jerram <neil@ossau.uklinux.net>2009-12-27 16:59:54 +0000
committerNeil Jerram <neil@ossau.uklinux.net>2009-12-27 16:59:54 +0000
commit3e5aed1c3be296b92f3a21e0dfde315deaef9daa (patch)
tree826150939f1707e036247d4de5f2bce632ea264e
parent0ca3a342d19ec89b8ae6bba0a74f0f9ecc5cf7c2 (diff)
downloadguile-3e5aed1c3be296b92f3a21e0dfde315deaef9daa.tar.gz
Add support for getsid
* configure.ac: Check availability of getsid() C library call. * libguile/posix.c (scm_getsid): New primitive. * libguile/posix.h: Declaration for new primitive.
-rw-r--r--configure.ac2
-rw-r--r--libguile/posix.c12
-rw-r--r--libguile/posix.h1
3 files changed, 14 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 35c2ed93b..5143dcc13 100644
--- a/configure.ac
+++ b/configure.ac
@@ -765,7 +765,7 @@ AC_CHECK_HEADERS([assert.h crt_externs.h])
# strcoll_l, newlocale - GNU extensions (glibc), also available on Darwin
# nl_langinfo - X/Open, not available on Windows.
#
-AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid fesetround ftime ftruncate fchown getcwd geteuid gettimeofday gmtime_r ioctl lstat mkdir mknod nice pipe _pipe readdir_r readdir64_r readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction siginterrupt stat64 strftime strptime symlink sync sysconf tcgetpgrp tcsetpgrp times uname waitpid strdup system usleep atexit on_exit chown link fcntl ttyname getpwent getgrent kill getppid getpgrp fork setitimer getitimer strchr strcmp index bcopy memcpy rindex truncate unsetenv isblank _NSGetEnviron strcoll strcoll_l newlocale nl_langinfo])
+AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid fesetround ftime ftruncate fchown getcwd geteuid getsid gettimeofday gmtime_r ioctl lstat mkdir mknod nice pipe _pipe readdir_r readdir64_r readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction siginterrupt stat64 strftime strptime symlink sync sysconf tcgetpgrp tcsetpgrp times uname waitpid strdup system usleep atexit on_exit chown link fcntl ttyname getpwent getgrent kill getppid getpgrp fork setitimer getitimer strchr strcmp index bcopy memcpy rindex truncate unsetenv isblank _NSGetEnviron strcoll strcoll_l newlocale nl_langinfo])
# Reasons for testing:
# netdb.h - not in mingw
diff --git a/libguile/posix.c b/libguile/posix.c
index 5187ff943..ef52c38f6 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -983,6 +983,18 @@ SCM_DEFINE (scm_setsid, "setsid", 0, 0, 0,
#undef FUNC_NAME
#endif /* HAVE_SETSID */
+#ifdef HAVE_GETSID
+SCM_DEFINE (scm_getsid, "getsid", 1, 0, 0,
+ (SCM pid),
+ "Returns the session ID of process @var{pid}. (The session\n"
+ "ID of a process is the process group ID of its session leader.)")
+#define FUNC_NAME s_scm_getsid
+{
+ return scm_from_int (getsid (scm_to_int (pid)));
+}
+#undef FUNC_NAME
+#endif /* HAVE_GETSID */
+
/* ttyname returns its result in a single static buffer, hence
scm_i_misc_mutex for thread safety. In glibc 2.3.2 two threads
diff --git a/libguile/posix.h b/libguile/posix.h
index 417133257..430d75b7f 100644
--- a/libguile/posix.h
+++ b/libguile/posix.h
@@ -33,6 +33,7 @@ SCM_API SCM scm_tcsetpgrp (SCM port, SCM pgid);
SCM_API SCM scm_tcgetpgrp (SCM port);
SCM_API SCM scm_ctermid (void);
SCM_API SCM scm_setsid (void);
+SCM_API SCM scm_getsid (SCM pid);
SCM_API SCM scm_setpgid (SCM pid, SCM pgid);
SCM_API SCM scm_pipe (void);
SCM_API SCM scm_getgroups (void);