delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/01/31/06:29:25

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_TD,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
Message-ID: <4D46A30D.2010706@gmail.com>
Date: Mon, 31 Jan 2011 11:54:53 +0000
From: Dave Korn <dave DOT korn DOT cygwin AT gmail DOT com>
User-Agent: Thunderbird 2.0.0.17 (Windows/20080914)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: On "write" command
References: <4D441414 DOT 1010407 AT alice DOT it> <4D4615E0 DOT 9040903 AT cygwin DOT com>
In-Reply-To: <4D4615E0.9040903@cygwin.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On 31/01/2011 01:52, Larry Hall (Cygwin) wrote:
> On 1/29/2011 8:20 AM, Angelo Graziosi wrote:
>> I would ask if on Cygwin I can use the 'write' command:
>>
>> write - send a message to another user
>>
>> $ write USER [ttyname]
>>
>> I remember I have used it some years ago, but not remember if it was on
>> GNU/Linux or Cygwin.
>>
>> I did a research on http://cygwin.com/packages and didn't find it, but
>> perhaps I did the wrong search..
> 
> No, that's the correct place to search.  If it's not showing up, none of
> the current packages provide 'write'.

  It's part of util-linux, but it's configured out of the build on Cygwin,
because it relies on a working utmp file to operate.  Which we don't have.
Hmm, I'm in the middle of a gcc testrun right now and can't rebuild my DLL,
but I noticed a few "interesting" points about the code:

winsup/cygwin/include/utmpx.h

> /* Must be kept in sync with struct utmp as defined in sys/utmp.h! */
> struct utmpx
> {
>  short	ut_type;
>  pid_t	ut_pid;
>  char	ut_line[UT_LINESIZE];
>  char   ut_id[UT_IDLEN];
>  time_t ut_time;
>  char	ut_user[UT_NAMESIZE];
>  char	ut_host[UT_HOSTSIZE];
>  long	ut_addr;
>  struct timeval ut_tv;
> };

winsup/cygwin/include/sys/utmp.h

> struct utmp
> {
>  short	ut_type;
>  pid_t	ut_pid;
>  char	ut_line[UT_LINESIZE];
>  char  ut_id[UT_IDLEN];
>  time_t ut_time;
>  char	ut_user[UT_NAMESIZE];
>  char	ut_host[UT_HOSTSIZE];
>  long	ut_addr;
> };

  That could explain why successive calls to getutent() appear to "lose frame"
across the contents of utmp.  Also,

winsup/cygwin/syscalls.cc

> /* Note: do not make NO_COPY */
> static struct utmp utmp_data_buf[16];
> static unsigned utix = 0;
> #define nutdbuf (sizeof (utmp_data_buf) / sizeof (utmp_data_buf[0]))
> #define utmp_data ({ \
>   if (utix > nutdbuf) \
>     utix = 0; \
>   utmp_data_buf + utix++; \
> })

  I haven't slept all night, but isn't that going to overrun by one?  Anyway
with the fix to utmp.h to add ut_tv (and a #include <sys/time.h>), write.exe
compiles and works...

    cheers,
      DaveK


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019