aboutsummaryrefslogtreecommitdiffstats
path: root/lang/tclX/files/patch-session
blob: 210ddd82f1a6ffee2a8ce4ae01f232313e39eb69 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
From

https://sourceforge.net/tracker/index.php?func=detail&aid=1656350&group_id=13247&atid=313247

    -mi

*** doc/TclX.n  2004-11-22 16:58:20.000000000 -0500
--- doc/TclX.n  2009-03-14 23:41:19.000000000 -0400
***************
*** 221,226 ****
--- 221,234 ----
  \fBwait\fR command has full functionality.  \fB0\fR if the \fBwait\fR
  command has limited functionality.
  .TP
+ \fBhave_getsid\fR
+ Return \fB1\fR if the \fBgetsid\fR system call is available.
+ If it is, the \fBid process session\fR command may be used.
+ .TP
+ \fBhave_setsid\fR
+ Return \fB1\fR if the \fBsetsid\fR system call is available.
+ If it is, the \fBid process session set\fR command may be used.
+ .TP
  \fBappname\fR
  Return the symbolic application name of the current application linked with
  the Extended Tcl library.  The C variable \fBtclAppName\fR must be set by the
***************
*** 736,741 ****
--- 744,755 ----
  \fBid process group set\fR
  Set the process group ID of the current process to its process ID.
  .TP
+ \fBid process session\fR
+ Return the session ID of the current process.
+ .TP
+ \fBid process session set\fR
+ Set the process session ID of the current process to be a session leader.
+ .TP
  \fBid host\fR
  Returns the standard host name of the machine the process is executing on.
  .IP
*** generic/tclXgeneral.c   Mon May  7 13:16:47 2001
--- generic/tclXgeneral.c   Sun Oct 14 17:54:28 2001
***************
*** 274,279 ****
--- 274,295 ----
  #       endif        
          return TCL_OK;
      }
+     if (STREQU ("have_getsid", optionPtr)) {
+ #       if (!defined(NO_GETSID)) && (!defined(WIN32))
+         Tcl_SetBooleanObj (resultPtr, TRUE);
+ #       else
+         Tcl_SetBooleanObj (resultPtr, FALSE);
+ #       endif        
+         return TCL_OK;
+     }
+     if (STREQU ("have_setsid", optionPtr)) {
+ #       if (!defined(NO_SETSID)) && (!defined(WIN32))
+         Tcl_SetBooleanObj (resultPtr, TRUE);
+ #       else
+         Tcl_SetBooleanObj (resultPtr, FALSE);
+ #       endif        
+         return TCL_OK;
+     }
      if (STREQU ("appname", optionPtr)) {
          if (tclAppName != NULL) {
              Tcl_SetStringObj (resultPtr, tclAppName, -1);
***************
*** 302,307 ****
--- 318,324 ----
                            "have_fchown, have_fchmod, have_flock, ",
                            "have_fsync, have_ftruncate, have_msgcats, ",
                            "have_symlink, have_truncate, ",
+                           "have_getsid, have_setsid, ",
                            "have_posix_signals, have_waitpid, appname, ",
                            "applongname, appversion, or apppatchlevel",
                            (char *) NULL);
*** unix/tclXunixId.c   Thu Dec  2 20:02:08 1999
--- unix/tclXunixId.c   Fri Oct 12 15:09:13 2001
***************
*** 133,138 ****
--- 133,140 ----
   *        id process parent
   *        id process group
   *        id process group set
+  *        id process session
+  *        id process session set
   *
   *        id effective user
   *        id effective userid
***************
*** 317,323 ****
  }
  
  /*
!  * id process ?parent|group? ?set?
   */
  static int
  IdProcess (interp, objc, objv)
--- 319,325 ----
  }
  
  /*
!  * id process ?parent|group|session? ?set?  
   */
  static int
  IdProcess (interp, objc, objv)
***************
*** 332,338 ****
      if (objc > 4)
          return TclX_WrongArgs (interp, 
                   objv [0], 
!                  "process ?parent|group? ?set?");
  
      if (objc == 2) {
    Tcl_SetObjResult (interp, Tcl_NewIntObj (getpid ()));
--- 334,340 ----
      if (objc > 4)
          return TclX_WrongArgs (interp, 
                   objv [0], 
!                  "process ?parent|group|session? ?set?");
  
      if (objc == 2) {
    Tcl_SetObjResult (interp, Tcl_NewIntObj (getpid ()));
***************
*** 373,381 ****
  #endif
          return TCL_OK;
      }
  
!     TclX_AppendObjResult (interp, "expected one of \"parent\" or \"group\" ",
!                           "got\"", subCommand, "\"", (char *) NULL);
      return TCL_ERROR;
  }
  
--- 375,410 ----
  #endif
          return TCL_OK;
      }
+     if (STREQU (subCommand, "session")) {
+         if (objc == 3) {
+ #ifndef NO_GETSID
+       Tcl_SetObjResult (interp, Tcl_NewIntObj (getsid (0)));
+ #endif
+             return TCL_OK;
+         }
+   trailerCommand = Tcl_GetStringFromObj (objv[3], NULL);
+         if ((objc != 4) || !STREQU (trailerCommand, "set"))
+             return TclX_WrongArgs (interp, objv [0], 
+                               " process session ?set?");
+ 
+         if (Tcl_IsSafe (interp)) {
+             TclX_AppendObjResult (interp,  "can't set process session from a ",
+                                   "safe interpeter", (char *) NULL);
+             return TCL_ERROR;
+         }
+ #ifndef NO_SETSID
+   if (setsid () == -1 ) {
+       TclX_AppendObjResult (interp,  "session set failed, process is ",
+               "already session leader", (char *) NULL);
+             return TCL_ERROR;
+   }
+   return TCL_OK;
+ #endif
+     }
  
!     TclX_AppendObjResult (interp, "expected one of \"parent\", \"group\" ",
!                           "or \"session\" ",
!                           "got \"", subCommand, "\"", (char *) NULL);
      return TCL_ERROR;
  }