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.

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