Return-Path: exmh-mail-errors@parc.xerox.com 
Return-Path: <exmh-mail-errors@parc.xerox.com>
Received: from Eng.Sun.COM (engmail1.Eng.Sun.COM) by sage.Eng.Sun.COM (5.x/SMI-SVR4)
	id AA19484; Fri, 27 Oct 1995 02:34:39 -0700
Received: from mercury.Sun.COM (mercury.EBay.Sun.COM) by Eng.Sun.COM (5.x/SMI-5.3)
	id AA18112; Fri, 27 Oct 1995 02:34:36 -0700
Received: from alpha.xerox.com by mercury.Sun.COM (Sun.COM)
	id CAA04662; Fri, 27 Oct 1995 02:34:36 -0700
Received: from mu.parc.xerox.com ([13.2.116.81]) by alpha.xerox.com with SMTP id <15326(9)>; Fri, 27 Oct 1995 02:10:10 PDT
Received: by mu.parc.xerox.com id <162703>; Fri, 27 Oct 1995 01:47:37 -0700
Received: from alpha.xerox.com ([13.1.64.93]) by mu.parc.xerox.com with SMTP id <162701>; Fri, 27 Oct 1995 01:47:10 -0700
Received: from hp.com ([15.255.152.4]) by alpha.xerox.com with SMTP id <14700(3)>; Fri, 27 Oct 1995 01:46:43 PDT
Received: from hazel.pwd.hp.com by hp.com with ESMTP
	(1.37.109.16/15.5+ECS 3.3) id AA266433595; Fri, 27 Oct 1995 01:46:36 -0700
Received: from localhost by hazel.pwd.hp.com with SMTP
	(1.39.111.2/16.2) id AA077983582; Fri, 27 Oct 1995 08:46:22 GMT
Message-Id: <199510270846.AA266433595@hp.com>
X-Mailer: exmh version 1.6.4 10/10/95
To: Paolo Brutti <gi0570@rh0015.roma.tlsoft.it>
Cc: exmh-users@parc.xerox.com
Subject: Re: VUE exmh wrapper 
In-Reply-To: Your message of "Fri, 27 Oct 1995 08:42:53 +0100."
             <9510270742.AA09717@rh0015.roma.tlsoft.it> 
Mime-Version: 1.0
	boundary="===_0_Fri_Oct_27_08:29:38_GMT_1995"
Date: Fri, 27 Oct 1995 01:46:22 PDT
From: John Haxby <jch@hazel.pwd.hp.com>
Sender: exmh-mail-errors@parc.xerox.com
Precedence: bulk
X-Comment: (Un)subscription requests to exmh-users-request@parc.xerox.com
Content-Type: multipart/mixed ;
	boundary="===_0_Fri_Oct_27_08:29:38_GMT_1995"
Content-Length: 4602

This is a multipart MIME message.

--===_0_Fri_Oct_27_08:29:38_GMT_1995
Content-Type: text/plain; charset=us-ascii

> I installed exmh a few weeks ago and I kept getting your same error
> about SIGCHILD being ignored.
> Only recently I discovered that this was caused by VUE, so, being a new
> UNIX user, I am currently starting exmh only from an xterm.
> Could you please send me your wrapper?

OK, assume one has got it, then so has everyone else :-)

Attached, without warranty express or implied, and no support from me or my employer and no liability either, you'll find several things.  The first are some actions, excerpts from user-prefs.vf or standalone files, doesn't really matter.  The important thing is that the "Mailer" action eventually results in "detach exmh" ...

--===_0_Fri_Oct_27_08:29:38_GMT_1995
Content-Type: text/plain; charset=us-ascii
Content-Description: VUE actions

#
# These can all go in ~/.vue/types/user-prefs.vf.  See the description for
# customizing your mailer, editor and terminal emulator in the on-line help.
#
ACTION Mailer
	TYPE		MAP		Exmh
END

ACTION  MailAFile
	TYPE		MAP		ExmhFile
END

ACTION Exmh
	TYPE		COMMAND
	EXEC-STRING	detach exmh
	WINDOW-TYPE	NO-STDIO
END

ACTION ExmhFile
	DESCRIPTION	Mail one or more files using exmh 
	TYPE		COMMAND
	EXEC-STRING	mailfile %(File)Arg_1"Files:"% %(File)Args%
	WINDOW-TYPE	NO-STDIO
END


--===_0_Fri_Oct_27_08:29:38_GMT_1995
Content-Type: text/plain; charset=us-ascii
Content-Description: ... continued ...

The "detach" command is a little C-program that runs whatever you tell it.  It's a like running something in the background except that it detaches the process from a terminal and, most importantly for HP VUE, sets SIGCHLD to SIG_DFL.

The ExmhFile action replaces the old MailxFile action that is invoked then you drop a file on the mail icon.  For those that don't know and do care, this action used to invoke mailx with a subject and recipient prompted from a dialog box.  ExmhFile runs the attached wish script to create a MIME bodypart for the file(s) and throws the whole lot at exmh.  I haven't tried the mailfile script extensively, so it's bound to fail in interesting ways if you use it in anger:-)

jch

--===_0_Fri_Oct_27_08:29:38_GMT_1995
Content-Type: application/x-c-source; charset=us-ascii
Content-Description: detach.c

#include <unistd.h>
#include <signal.h>

main (int argc, char *argv[])
{
    int pid, fd, i;

    if ((pid = fork()) < 0) {
	perror ("fork");
	exit (1);
    }
    if (pid != 0)
	exit (0);

    fd = open ("/dev/null", 2);
    dup2 (fd, 0);
    dup2 (fd, 1);
    dup2 (fd, 2);
    for (i = 3; i < 64; i++)
	close (i);
    setsid ();
    signal (SIGCHLD, SIG_DFL);
    argv++;
    execvp (*argv, argv);
}

--===_0_Fri_Oct_27_08:29:38_GMT_1995
Content-Type: application/x-tcl
Content-Description: mailfile

#!/bin/sh
# -*- tcl -*- \
exec wish "$0" ${1+"$@"}

wm withdraw .
#
# Create a draft file.  This mechanism isn't perfect, there's a window,
# but it is slightly safer than nothing at all
#
set draftfolder [string trimleft [exec mhparam draft-folder] +]

while {1} {
    set draftfile [exec mhpath +$draftfolder new]
    if ![catch {open $draftfile {WRONLY CREAT EXCL}} draftfd] {
	break
    }
}

foreach arg $argv {
    lappend subject $argv
}
if ![info exists subject] {
    set subject "<stdin>"
}
puts $draftfd "To: \nCc: \nSubject: $subject"
puts $draftfd "Mime-Version: 1.0"
set boundary "_=[exec date]=_"
puts $draftfd "Content-type: multipart/mixed; boundary=\"$boundary\"\n"

puts $draftfd "--$boundary"
puts $draftfd "Content-type: text/plain\n"
puts $draftfd "\t\[Introductory Text]\n"

if {[llength $argv] == 0} {
    puts $draftfd "--$boundary"
    puts $draftfd "Content-type: text/plain\n"
    while {![eof stdin]} {
	set bytes [read stdin 8192]
	puts -nonewline $draftfd $bytes
    }
    if ![string match "*\n" $bytes] {
	puts $draftfd ""
    }
    puts $draftfd "--$boundary--"
} else {
    foreach arg $argv {
	puts $draftfd "--$boundary"
	switch -glob -- $arg {
	    *.ps {set type "application/postscript"}
	    * {set type "text/plain"}
	}
	puts $draftfd "Content-type: $type"
	puts $draftfd "Content-description: $arg\n"

	if [catch {open $arg r} fd] {
	    puts $draftfd "\t$arg: $fd"
	} else {
	    while {![eof $fd]} {
		set bytes [read $fd 8192]
		puts -nonewline $draftfd $bytes
	    }
	    close $fd
	    if ![string match "*\n" $bytes] {
		puts $draftfd ""
	    }
	}
    }
    puts $draftfd "--$boundary--"
}

close $draftfd
send exmh Msg_CompUse $draftfolder [file tail $draftfile]
destroy .

--===_0_Fri_Oct_27_08:29:38_GMT_1995--



