OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

195 lines
4.8 KiB

  1. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # Filename: package/.../pdksh/pdksh-5.2.14-1.patch
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. # Copyright (C) 1998 - 2003 Clifford Wolf
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This patch file is dual-licensed. It is available under the license the
  11. # patched project is licensed under, as long as it is an OpenSource license
  12. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  13. # of the GNU General Public License as published by the Free Software
  14. # Foundation; either version 2 of the License, or (at your option) any later
  15. # version.
  16. # --- SDE-COPYRIGHT-NOTE-END ---
  17. [ ftp://ftp.cs.mun.ca/pub/pdksh/pdksh-5.2.14-patches.1 ]
  18. Here are patches for 3 significant bugs in pdksh-5.2.14:
  19. - set -x dumps core (shf.c);
  20. - output of "jobs" command is filled with ^A characters (jobs.c);
  21. - "typeset -r foo=bar" fails saying foo is readonly (var.c).
  22. --- ./shf.c
  23. +++ ./shf.c
  24. @@ -355,7 +355,6 @@
  25. shf->rp = nbuf + (shf->rp - shf->buf);
  26. shf->wp = nbuf + (shf->wp - shf->buf);
  27. shf->rbsize += shf->wbsize;
  28. - shf->wbsize += shf->wbsize;
  29. shf->wnleft += shf->wbsize;
  30. shf->wbsize *= 2;
  31. shf->buf = nbuf;
  32. --- ./var.c
  33. +++ ./var.c
  34. @@ -353,7 +353,9 @@
  35. const char *s;
  36. int error_ok;
  37. {
  38. - if (vq->flag & RDONLY) {
  39. + int no_ro_check = error_ok & 0x4;
  40. + error_ok &= ~0x4;
  41. + if ((vq->flag & RDONLY) && !no_ro_check) {
  42. warningf(TRUE, "%s: is read only", vq->name);
  43. if (!error_ok)
  44. errorf(null);
  45. @@ -715,13 +717,13 @@
  46. if (val != NULL) {
  47. if (vp->flag&INTEGER) {
  48. /* do not zero base before assignment */
  49. - setstr(vp, val, KSH_UNWIND_ERROR);
  50. + setstr(vp, val, KSH_UNWIND_ERROR | 0x4);
  51. /* Done after assignment to override default */
  52. if (base > 0)
  53. vp->type = base;
  54. } else
  55. /* setstr can't fail (readonly check already done) */
  56. - setstr(vp, val, KSH_RETURN_ERROR);
  57. + setstr(vp, val, KSH_RETURN_ERROR | 0x4);
  58. }
  59. /* only x[0] is ever exported, so use vpbase */
  60. --- ./jobs.c
  61. +++ ./jobs.c
  62. @@ -219,8 +219,7 @@
  63. static void check_job ARGS((Job *j));
  64. static void put_job ARGS((Job *j, int where));
  65. static void remove_job ARGS((Job *j, const char *where));
  66. -static void kill_job ARGS((Job *j));
  67. -static void fill_command ARGS((char *c, int len, struct op *t));
  68. +static int kill_job ARGS((Job *j, int sig));
  69. /* initialize job control */
  70. void
  71. @@ -294,10 +293,17 @@
  72. && procpid == kshpid)))))
  73. {
  74. killed = 1;
  75. - killpg(j->pgrp, SIGHUP);
  76. + if (j->pgrp == 0)
  77. + kill_job(j, SIGHUP);
  78. + else
  79. + killpg(j->pgrp, SIGHUP);
  80. #ifdef JOBS
  81. - if (j->state == PSTOPPED)
  82. - killpg(j->pgrp, SIGCONT);
  83. + if (j->state == PSTOPPED) {
  84. + if (j->pgrp == 0)
  85. + kill_job(j, SIGCONT);
  86. + else
  87. + killpg(j->pgrp, SIGCONT);
  88. + }
  89. #endif /* JOBS */
  90. }
  91. }
  92. @@ -497,7 +503,7 @@
  93. put_job(j, PJ_PAST_STOPPED);
  94. }
  95. - fill_command(p->command, sizeof(p->command), t);
  96. + snptreef(p->command, sizeof(p->command), "%T", t);
  97. /* create child process */
  98. forksleep = 1;
  99. @@ -508,7 +514,7 @@
  100. forksleep <<= 1;
  101. }
  102. if (i < 0) {
  103. - kill_job(j);
  104. + kill_job(j, SIGKILL);
  105. remove_job(j, "fork failed");
  106. #ifdef NEED_PGRP_SYNC
  107. if (j_sync_open) {
  108. @@ -823,11 +829,10 @@
  109. }
  110. if (j->pgrp == 0) { /* started when !Flag(FMONITOR) */
  111. - for (p=j->proc_list; p != (Proc *) 0; p = p->next)
  112. - if (kill(p->pid, sig) < 0) {
  113. - bi_errorf("%s: %s", cp, strerror(errno));
  114. - rv = 1;
  115. - }
  116. + if (kill_job(j, sig) < 0) {
  117. + bi_errorf("%s: %s", cp, strerror(errno));
  118. + rv = 1;
  119. + }
  120. } else {
  121. #ifdef JOBS
  122. if (j->state == PSTOPPED && (sig == SIGTERM || sig == SIGHUP))
  123. @@ -1825,50 +1830,17 @@
  124. *
  125. * If jobs are compiled in then this routine expects sigchld to be blocked.
  126. */
  127. -static void
  128. -kill_job(j)
  129. +static int
  130. +kill_job(j, sig)
  131. Job *j;
  132. + int sig;
  133. {
  134. Proc *p;
  135. + int rval = 0;
  136. for (p = j->proc_list; p != (Proc *) 0; p = p->next)
  137. if (p->pid != 0)
  138. - (void) kill(p->pid, SIGKILL);
  139. -}
  140. -
  141. -/* put a more useful name on a process than snptreef does (in certain cases) */
  142. -static void
  143. -fill_command(c, len, t)
  144. - char *c;
  145. - int len;
  146. - struct op *t;
  147. -{
  148. - int alen;
  149. - char **ap;
  150. -
  151. - if (t->type == TEXEC || t->type == TCOM) {
  152. - /* Causes problems when set -u is in effect, can also
  153. - cause problems when array indices evaluated (may have
  154. - side effects, eg, assignment, incr, etc.)
  155. - if (t->type == TCOM)
  156. - ap = eval(t->args, DOBLANK|DONTRUNCOMMAND);
  157. - else
  158. - */
  159. - ap = t->args;
  160. - --len; /* save room for the null */
  161. - while (len > 0 && *ap != (char *) 0) {
  162. - alen = strlen(*ap);
  163. - if (alen > len)
  164. - alen = len;
  165. - memcpy(c, *ap, alen);
  166. - c += alen;
  167. - len -= alen;
  168. - if (len > 0) {
  169. - *c++ = ' '; len--;
  170. - }
  171. - ap++;
  172. - }
  173. - *c = '\0';
  174. - } else
  175. - snptreef(c, len, "%T", t);
  176. + if (kill(p->pid, sig) < 0)
  177. + rval = -1;
  178. + return rval;
  179. }