Newsgroups: comp.sys.3b1 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!utopia!raj From: raj@utopia.calvin.edu (Ross A. Jekel;;;772-4870;ATRajT Unix PC) Subject: Problems with system() call Message-ID: Summary: Need help with system() call. Keywords: TeX, system() call Sender: news@engin.umich.edu (CAEN Netnews) Organization: The University of Michigan, Ann Arbor Date: 29 Apr 91 17:21:08 GMT Hi, I'm compiling, or rather have compiled, TeX 3.14 and METAFONT 2.7 on my Unix-PC. I got the medium TeX change files from Andy off the network and have a runable TeX of about 2.0 meg. (The size command gives me the breakdown of about 170000 (text) + 80 (data) + 1800000 (bss) + 0 (lib)). My problem is that the code for implimenting the edit option when there is an error in the .tex file uses a system(command) call, where command contains the string to start up your favorite editor at the correct line. When I try to use the edit option, the system call fails. My hunch is that system is implimented somethink like this (in psuedo code of course): int system(command) char *command; { call to fork; if parent wait else do an execl call on /bin/sh with the command; return return-value; } I think that the system call fails because fork makes an exact copy of the program that calls fork and that my machine just doesn't have the memory or swap space to give that much memory out to another process. (Which is logical since I cannot run more than one TeX of METAFONT process at once.) Since the TeX C code just did an exit(1) right after the system() call, I decided to hardcode in an execl call something like: if (execl("/usr/bin/vi", "vi", number, file, (char *) 0) == -1) printf("! Trouble executing editor command.\n"); where number is a pointer to a string that contains "+d%d" where %d is replaced with the line number that contains the error and file is a pointer to the filename. This is fine for me, but I would like to post the binaries to the OSU archives and I know that their are people out there that may want to set the TEXEDIT variable to something other than vi. I could try to break up the arguments of the command and then call execl, but I was wondering if there was an easier way. (maybe something like if (execl("/bin/sh", "sh", "exec", command, (char *) 0) == -1) etc. ), which I don't think works (but would be nice if it did.) Any suggestions would be appreciated. And please don't tell me just to make the small memory versions of TeX and METAFONT because there is a font in the Computer Modern family that runs out of memory when the small version of METAFONT tries to make it. Also, for anyone that cares, I modified a change that the C version of TeX has. C TeX 3.14 first looks for the file 'foo' if you say 'tex foo' and then looks for foo.tex. To me, this is backwards since I use cweb and usually have the files prog.w prog.c prog.tex prog in my directory (where prog is obviously the executable from prog.c). But, if I then type 'tex prog' it starts TeX'ing the executable file. So, I changed their code so that it first looks for foo.tex and then foo. If anyone has any problems with this modification, I suppose I could post the programs without it. Thanks for the help, Send mail to s83949@ursa.calvin.edu or post an answer. Ross A. Jekel