Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 88 lines (74 sloc) 1.986 kb
4ecaa511 » orebokech
2011-12-09 Import upstream snapshot from SVN r2647
1 /* $Id: osdep-sunos.c 2647 2011-12-09 16:37:29Z nicm $ */
8fade26b » Karl Ferdinand Ebert
2009-11-22 Imported Upstream version 1.1
2
3 /*
4 * Copyright (c) 2009 Todd Carson <toc@daybefore.net>
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/stat.h>
21
7216c39c » kfebert
2011-07-09 Imported Upstream version 1.5
22 #include <event.h>
8fade26b » Karl Ferdinand Ebert
2009-11-22 Imported Upstream version 1.1
23 #include <fcntl.h>
24 #include <procfs.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <unistd.h>
28
29 #include "tmux.h"
30
31 char *
32 osdep_get_name(int fd, char *tty)
33 {
34 struct psinfo p;
35 struct stat st;
36 char *path;
37 ssize_t bytes;
38 int f;
39 pid_t pgrp;
40
41 if ((f = open(tty, O_RDONLY)) < 0)
42 return (NULL);
43
b0169484 » orebokech
2011-10-03 Import upstream snapshot from SVN r2608
44 if (fstat(f, &st) != 0 || ioctl(f, TIOCGPGRP, &pgrp) != 0) {
8fade26b » Karl Ferdinand Ebert
2009-11-22 Imported Upstream version 1.1
45 close(f);
46 return (NULL);
47 }
48 close(f);
49
b0169484 » orebokech
2011-10-03 Import upstream snapshot from SVN r2608
50 xasprintf(&path, "/proc/%u/psinfo", (u_int) pgrp);
8fade26b » Karl Ferdinand Ebert
2009-11-22 Imported Upstream version 1.1
51 f = open(path, O_RDONLY);
52 xfree(path);
53 if (f < 0)
54 return (NULL);
55
56 bytes = read(f, &p, sizeof(p));
57 close(f);
58 if (bytes != sizeof(p))
59 return (NULL);
60
61 if (p.pr_ttydev != st.st_rdev)
62 return (NULL);
63
64 return (xstrdup(p.pr_fname));
65 }
7216c39c » kfebert
2011-07-09 Imported Upstream version 1.5
66
4ecaa511 » orebokech
2011-12-09 Import upstream snapshot from SVN r2647
67 char *
68 osdep_get_cwd(pid_t pid)
69 {
70 static char target[MAXPATHLEN + 1];
71 char *path;
72 ssize_t n;
73
74 xasprintf(&path, "/proc/%u/path/cwd", (u_int) pid);
75 n = readlink(path, target, MAXPATHLEN);
76 xfree(path);
77 if (n > 0) {
78 target[n] = '\0';
79 return (target);
80 }
81 return (NULL);
82 }
83
7216c39c » kfebert
2011-07-09 Imported Upstream version 1.5
84 struct event_base *
85 osdep_event_init(void)
86 {
87 return (event_init());
88 }
Something went wrong with that request. Please try again.