[comp.sys.3b1] Problems with system

raj@utopia.calvin.edu (Ross A. Jekel;;;772-4870;ATRajT Unix PC) (04/30/91)

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

dnichols@ceilidh.beartrack.com (DoN Nichols) (05/01/91)

In article <raj.672945668@utopia> raj@utopia.calvin.edu (Ross A. Jekel;;;772-4870;ATRajT Unix PC) writes:
>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

	[ ... ]
>
>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

	Have you tried increasing the swap space?  As long as a single
process doesn't take more than 4MB, you should be able to do the fork().
(Increasing the swap space as an afterthought can be a pain, since you have
to back up everything (and don't forget that the backup under UA skips the
foundation set, and any file which is timestamped as being older than the
install date of the foundation set), then you re-format using the improved
diagnostic disk from osu-cis, in expert mode.

	Good Luck
		DoN.
-- 
Donald Nichols (DoN.)		| Voice (Days):	(703) 664-1585
D&D Data			| Voice (Eves):	(703) 938-4564
Disclaimer: from here - None	| Email:     <dnichols@ceilidh.beartrack.com>
	--- Black Holes are where God is dividing by zero ---