mirror of the now-defunct rocklinux.org
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.

197 lines
4.9 KiB

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