home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / atari / st / tech / 4396 < prev    next >
Encoding:
Internet Message Format  |  1992-08-12  |  2.6 KB

  1. Path: sparky!uunet!pipex!unipalm!uknet!fulcrum!its!silver.its.bt.co.uk!jvt
  2. From: jvt@its.bt.co.uk (John Trickey)
  3. Newsgroups: comp.sys.atari.st.tech
  4. Subject: Re: Null arguments with ARGV
  5. Message-ID: <1992Aug12.163035.9518@its.bt.co.uk>
  6. Date: 12 Aug 92 16:30:35 GMT
  7. References: <HOHMUTH.92Aug7135701@freia.freia.inf.tu-dresden.de> <1992Aug7.173202.23520@mnemosyne.cs.du.edu> <1992Aug11.125823@disuns2.epfl.ch>
  8. Sender: @its.bt.co.uk
  9. Organization: BT Group Computing Unix Support, Birmingham, UK
  10. Lines: 49
  11.  
  12. I have been following this thread with more than a little bemusement at
  13. the intricasies of passing args through TOS. Probably the way to have
  14. avoided all of this would have stored the *argv[] array in the parent
  15. and passed a pointer to the child, yes in the environment if you have
  16. to!
  17.  
  18. However, we do not have a clean slate so compatibility must be
  19. paramount. First we must consider that old applications being passed a
  20. null arg will fail anyway. That means we only need consider new
  21. applications as long as we leave ARGV untouched.
  22.  
  23. So now we must mandate a new variable (say ARGN --- call it what you
  24. want) which will hold pointers to the null args. 
  25.  
  26. > app arg1 "" arg3 "" arg5
  27.  
  28. wil produce
  29. ARGN=2,4
  30. ARGV=\bin\app\0arg1\0arg3\0arg5\0\0
  31.  
  32. All we are left with is the "validity of ARGN" problem. Well, since GEM
  33. only copies the environment up to the first \0\0, then ARGV **must** be
  34. the last entry in the environment for this mechanism to work. Similary
  35. for the exec mechanism to work, ARGN will be the penultimate entry and
  36. for it to be valid
  37.     (getenv(ARGV) == (getenv(ARGN)+strlen(getenv(ARGN))+6))
  38. Now this is not perfect as a non conforming application that execs could
  39. pass on ARGN and ARGV in that configuration and so lead to chaos.
  40. Conforming applications could remove the ARGN value after use on startup
  41. which would limit the damage but its only really a partial cure.
  42.  
  43. Umm, coming back to the conclusion that all existing applications could
  44. potentially break, then there is little mileage in trying to bend the
  45. existing method to cope so why not consider a new method that will run
  46. alongside the existing argv? If the *argv[] array was stored in the
  47. child and pointed to the strings (or WHY) in the exec call, the address
  48. of argv could be passed as a hex represented string in the environment
  49. along with the current ARGV. The cost penalty is low at 4n + 4 bytes +
  50. new env variable. This should be alright as long as a child does not
  51. outlive its parent (MiNT etc?).
  52.  
  53. Hope I've provided some food for thought.
  54.  
  55. John
  56. -- 
  57. John Trickey <jvt@its.bt.co.uk>
  58.        Voice: +44 21 524 8200     Fax: +44 21 553 6120
  59. (Home) <john@its.bt.co.uk> || <john@g4rev.ampr.org> || G4REV @ GB7FLG
  60.        +44 21 308 8892
  61.