Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 69 lines (57 sloc) 1.85 kB
4ecaa51 @orebokech Import upstream snapshot from SVN r2647
orebokech authored
1 /* $Id: osdep-darwin.c 2647 2011-12-09 16:37:29Z nicm $ */
8fade26 Imported Upstream version 1.1
Karl Ferdinand Ebert authored
2
3 /*
4 * Copyright (c) 2009 Joshua Elsasser <josh@elsasser.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #include <sys/types.h>
20 #include <sys/sysctl.h>
21
7216c39 @kfebert Imported Upstream version 1.5
kfebert authored
22 #include <event.h>
8fade26 Imported Upstream version 1.1
Karl Ferdinand Ebert authored
23 #include <stdlib.h>
24 #include <string.h>
25 #include <unistd.h>
26
7216c39 @kfebert Imported Upstream version 1.5
kfebert authored
27 char *osdep_get_name(int, char *);
4ecaa51 @orebokech Import upstream snapshot from SVN r2647
orebokech authored
28 char *osdep_get_cwd(pid_t);
7216c39 @kfebert Imported Upstream version 1.5
kfebert authored
29 struct event_base *osdep_event_init(void);
8fade26 Imported Upstream version 1.1
Karl Ferdinand Ebert authored
30
31 #define unused __attribute__ ((unused))
32
33 char *
34 osdep_get_name(int fd, unused char *tty)
35 {
36 int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, 0 };
7216c39 @kfebert Imported Upstream version 1.5
kfebert authored
37 size_t size;
8fade26 Imported Upstream version 1.1
Karl Ferdinand Ebert authored
38 struct kinfo_proc kp;
39
40 if ((mib[3] = tcgetpgrp(fd)) == -1)
41 return (NULL);
42
43 size = sizeof kp;
44 if (sysctl(mib, 4, &kp, &size, NULL, 0) == -1)
45 return (NULL);
46 if (*kp.kp_proc.p_comm == '\0')
47 return (NULL);
48
49 return (strdup(kp.kp_proc.p_comm));
50 }
7216c39 @kfebert Imported Upstream version 1.5
kfebert authored
51
4ecaa51 @orebokech Import upstream snapshot from SVN r2647
orebokech authored
52 char *
53 osdep_get_cwd(pid_t pid)
54 {
55 return (NULL);
56 }
57
7216c39 @kfebert Imported Upstream version 1.5
kfebert authored
58 struct event_base *
59 osdep_event_init(void)
60 {
61 /*
62 * On OS X, kqueue and poll are both completely broken and don't
63 * work on anything except socket file descriptors (yes, really).
64 */
65 setenv("EVENT_NOKQUEUE", "1", 1);
66 setenv("EVENT_NOPOLL", "1", 1);
67 return (event_init());
68 }
Something went wrong with that request. Please try again.