Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rochester!rutgers!ames!oliveb!sun!gorodish!guy From: guy%gorodish@Sun.COM (Guy Harris) Newsgroups: comp.unix.wizards Subject: Re: multiple-machine executables for Suns? Message-ID: <24871@sun.uucp> Date: Tue, 4-Aug-87 20:01:37 EDT Article-I.D.: sun.24871 Posted: Tue Aug 4 20:01:37 1987 Date-Received: Thu, 6-Aug-87 07:05:38 EDT References: <1853@megaron.arizona.edu> <12646@sol.hi.UUCP> Sender: news@sun.uucp Lines: 30 > But more seriously, if I was going to design an a.out format that could > "run" everywhere I would have the compilers, loaders, etc output a psuedo > code and then have the kernal interpet the code. This will keep the > a.out small, but the will take FOREVER to execute. In a lot of UNIX systems, you already have that, and you don't have to stuff the interpreter into the kernel, and thus can avoid the effort of making large hunks of your kernel pageable or swappable (you don't want that pseudo-code interpreter wired down, do you?) or making those same hunks reloadable (you don't want to have to reboot when you change the interpreter, right?). The magic number is the string "#!"; just put the pathname of the interpreter after that, and have the interpreter understand that its first argument is the pathname of the file to be interpreted. If the interpreter takes flag arguments, you should have some flag that says "no argument after this one is a flag, even if it begins with '-'" and stick that after the name of the interpreter in the "#!" line. ("/bin/sh" has the "-" argument; the 4.3BSD C shell has "-b".) Of course, you can't safely use this for set-UID executables. The most obvious hole is closed by the above "this is the last argument" flag, and changes in 4.3 that cause the script name NOT to be passed as argv[0] fix the second-most-obvious hole; however, somebody pointed a fairly obscure hole out to me that is fixable only by some extra effort in the kernel, and there may be even more obscure holes after that one. Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com