[comp.emacs] emacs under ksh job control

john@beaudin.UUCP (John Beaudin) (12/23/90)

I've been using emacs for several months. It works as advertized
for my purposes.

Recently, I started using the korn shell (ksh) full-time.
My previous shell didn't have job control.
I decided to re-compile emacs with job control defined. I DID NOT
define NOMULTIPLEJOBS (see config.h below).

Emacs seemed to rebuild OK without error msgs.
However, when in emacs, when I type ^z, I get my ksh prompt and the shell
acts normal, but when I 'fg' I get stuck in some kind of twilight zone
where I can't see the whole screen. ^L doesn't give me
any refresh either. I am able to ^z back to a ksh sucessfully do a 'kill %1'.
This same behaviour exists for 'vi', but 'less' has no problem
refreshing the screen and acting normal. At least one script behaves, and
'find' works ok. I will phone SCO and ask them about vi.

I include here the contents of my emacs config.h include file.
I'm not going to mention the copyleft to save net bandwidth.
-------------------------------------------------------
/* GNU Emacs site configuration template file.
/*  Include local hack to use Xenix TICGETC iotcl call in sysdep.c */

/* #define HCR */
#ifdef HCR
#define LIBS_SYSTEM /usr/local/contrib/lib/gcc-1.36/gcc-gnulib
#endif /* HCR */
/* Include here a s- file that describes the system type you are using.
   See the file ../etc/MACHINES for a list of systems and
   the names of the s- files to use for them.
   See s-template.h for documentation on writing s- files.  */

#include "s-usg5-3.h"


#define HAVE_PTYS
#define SYSV_PTYS

/* Include here a m- file that describes the machine and system you use.
   See the file ../etc/MACHINES for a list of machines and
   the names of the m- files to use for them.
   See m-template.h for info on what m- files should define.
   */
#include "m-intel386.h"

/* Load in the conversion definitions if this system
   needs them and the source file being compiled has not
   said to inhibit this.  There should be no need for you
   to alter these lines.  */

#ifdef SHORTNAMES
#ifndef NO_SHORTNAMES
#include "../shortnames/remap.h"
#endif /* not NO_SHORTNAMES */
#endif /* SHORTNAMES */

/* Define HAVE_X_WINDOWS if you want to use the X window system.  */

/* #define HAVE_X_WINDOWS */

/* Define X11 if you want to use version 11 of X windows.
   Otherwise, Emacs expects to use version 10.  */

/* #define X11 */

/* Define HAVE_X_MENU if you want to use the X window menu system.
   This appears to work on some machines that support X
   and not on others.  */

/* #define HAVE_X_MENU */

/* Define `subprocesses' should be defined if you want to
   have code for asynchronous subprocesses
   (as used in M-x compile and M-x shell).
   These do not work for some USG systems yet;
   for the ones where they work, the s-*.h file defines this flag.  */

#ifndef VMS
#ifndef USG
#define subprocesses
#endif
#endif

/* Define USER_FULL_NAME to return a string
   that is the user's full name.
   It can assume that the variable `pw'
   points to the password file entry for this user.

   At some sites, the pw_gecos field contains
   the user's full name.  If neither this nor any other
   field contains the right thing, use pw_name,
   giving the user's login name, since that is better than nothing.  */

#define USER_FULL_NAME pw->pw_gecos

/* Define AMPERSAND_FULL_NAME if you use the convention
   that & in the full name stands for the login id.  */

/* #define AMPERSAND_FULL_NAME */

/* Maximum screen width we handle. */

#define MScreenWidth 300

/* Maximum screen length we handle. */

#define MScreenLength 300

/* # bytes of pure Lisp code to leave space for.
   Note that s-vms.h and m-sun2.h may override this default.  */

#ifndef PURESIZE
#ifdef HAVE_X_WINDOWS
#define PURESIZE 122000
#else
#define PURESIZE 118000
#endif
#endif

/* Define HIGHPRI as a negative number
   if you want Emacs to run at a higher than normal priority.
   For this to take effect, you must install Emacs with setuid root.
   Emacs will change back to the users's own uid after setting
   its priority.  */

/* #define HIGHPRI */
#undef LIBX10_SYSTEM
#undef LIBX11_SYSTEM
#define LIBX10_SYSTEM -linet -lnsl_s
#define LIBX11_SYSTEM -linet -lnsl_s

-- 
My .signature is awaiting apropriate display technology

mb@ttidca.TTI.COM (Michael Bloom) (12/25/90)

In article <1473@beaudin.UUCP> john@beaudin.UUCP (John Beaudin) writes:
	I've been using emacs for several months. It works as advertized
	for my purposes.

	Recently, I started using the korn shell (ksh) full-time.
	My previous shell didn't have job control.
	I decided to re-compile emacs with job control defined.

	However, when in emacs, when I type ^z, I get my ksh prompt and the 
	shell
	acts normal, but when I 'fg' I get stuck in some kind of twilight zone

Your problem may be similar to (or the same as) one experienced in gdb
by one of the people using my "stabs-in-coff" stuff on an SCO system.
Certainly your symptoms sound similar.

SCO uses the POSIX definitions of some of the facilities used for job control,
rather than the BSD definitions.  

The particular calls of interest are the bsd routines setpgrp() and
getpgrp(). SCO's setpgrp() is a superset of the System V routine of
the same name, and is probably implemented using the same (or nearly
the same) code as the POSIX setsid() routine.

Fortunately, posix does define a routine with the semantics you need. It's
called setpgid(), and behaves like the bsd setpgrp(). Similarly, the posix
routine getpgid() routine behaves like the bsd getpgrp().

I suspect that the fix for the problem you are having on SCO (and probably 
any other POSIX system) is to add this to your config file:

/* use setpgid(int pid, int pgrp), not setpgrp(void) on POSIX systems. */
#define setpgrp setpgid
#define getpgrp getpgid