Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Live in a world of your own, but always welcome visitors.


comp / comp.unix.programmer / Re: Faking a TTY on a pipe/socketpair

SubjectAuthor
* Faking a TTY on a pipe/socketpairMuttley
+* Re: Faking a TTY on a pipe/socketpairKenny McCormack
|`* Re: Faking a TTY on a pipe/socketpairMuttley
| +- Re: Faking a TTY on a pipe/socketpairWolfgang Agnes
| `* Re: Faking a TTY on a pipe/socketpairKenny McCormack
|  `- Re: Faking a TTY on a pipe/socketpairMuttley
+* Re: Faking a TTY on a pipe/socketpairKaz Kylheku
|+- Re: Faking a TTY on a pipe/socketpairMuttley
|`* Re: Faking a TTY on a pipe/socketpairEric Pozharski
| +- Re: Faking a TTY on a pipe/socketpairScott Lurndal
| `* Re: Faking a TTY on a pipe/socketpairKaz Kylheku
|  `- Re: Faking a TTY on a pipe/socketpairEric Pozharski
+* Re: Faking a TTY on a pipe/socketpairJanis Papanagnou
|+- Re: Faking a TTY on a pipe/socketpairMuttley
|`* Re: Faking a TTY on a pipe/socketpairRichard Kettlewell
| `- Re: Faking a TTY on a pipe/socketpairMuttley
`* Re: Faking a TTY on a pipe/socketpairRichard L. Hamilton
 +* Re: Faking a TTY on a pipe/socketpairMuttley
 |`* Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | +* Re: Faking a TTY on a pipe/socketpairMuttley
 | |`* Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | | +* Re: Faking a TTY on a pipe/socketpairKenny McCormack
 | | |`* Re: Faking a TTY on a pipe/socketpairDan Cross
 | | | `* Re: Faking a TTY on a pipe/socketpairKenny McCormack
 | | |  `- Re: Faking a TTY on a pipe/socketpairMuttley
 | | +- Re: Faking a TTY on a pipe/socketpairNicolas George
 | | `* Re: Faking a TTY on a pipe/socketpairMuttley
 | |  +* Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  |+- Re: Faking a TTY on a pipe/socketpairScott Lurndal
 | |  |+* Re: Faking a TTY on a pipe/socketpairMuttley
 | |  ||`* Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  || +* Re: Faking a TTY on a pipe/socketpairJohn Ames
 | |  || |`- Re: Faking a TTY on a pipe/socketpairScott Lurndal
 | |  || `* Re: Faking a TTY on a pipe/socketpairMuttley
 | |  ||  +* Windows-think and systemd (Was: Something completely unrelated to what we're yapKenny McCormack
 | |  ||  |+* Re: Windows-think and systemd (Was: Something completely unrelated to what we'reMuttley
 | |  ||  ||`* Re: Windows-think and systemd (Was: Something completely unrelated to what we'reRichard L. Hamilton
 | |  ||  || `- AIX (was Re: Windows-think and systemd)Janis Papanagnou
 | |  ||  |+- Re: Windows-think and systemd (Was: Something completely unrelated to what we'reKaz Kylheku
 | |  ||  |`- Re: Windows-think and systemd (Was: Something completely unrelated to what we'reJim Jackson
 | |  ||  +- Re: Faking a TTY on a pipe/socketpairRainer Weikusat
 | |  ||  `- Re: Faking a TTY on a pipe/socketpairRichard L. Hamilton
 | |  |+- Re: Faking a TTY on a pipe/socketpairRainer Weikusat
 | |  |+* Re: Faking a TTY on a pipe/socketpairJim Jackson
 | |  ||+* Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  |||`- Re: Faking a TTY on a pipe/socketpairRainer Weikusat
 | |  ||`* Re: Faking a TTY on a pipe/socketpairRichard Kettlewell
 | |  || `* Re: Faking a TTY on a pipe/socketpairMuttley
 | |  ||  +- Re: Faking a TTY on a pipe/socketpairJim Jackson
 | |  ||  `* Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  ||   +- Re: Faking a TTY on a pipe/socketpairRainer Weikusat
 | |  ||   `* Re: Faking a TTY on a pipe/socketpairMuttley
 | |  ||    `* Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  ||     +* Re: Faking a TTY on a pipe/socketpairJim Jackson
 | |  ||     |`* Re: Faking a TTY on a pipe/socketpairNicolas George
 | |  ||     | +* Re: Faking a TTY on a pipe/socketpairAlexis
 | |  ||     | |`- Re: Faking a TTY on a pipe/socketpairNicolas George
 | |  ||     | +* Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  ||     | |`* Re: Faking a TTY on a pipe/socketpairMuttley
 | |  ||     | | `- Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  ||     | `* Re: Faking a TTY on a pipe/socketpairJim Jackson
 | |  ||     |  `* Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  ||     |   `* Re: Faking a TTY on a pipe/socketpairJim Jackson
 | |  ||     |    `* Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  ||     |     `* Re: Faking a TTY on a pipe/socketpairJim Jackson
 | |  ||     |      `* Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  ||     |       `* Re: Faking a TTY on a pipe/socketpairJim Jackson
 | |  ||     |        `* Re: Faking a TTY on a pipe/socketpairScott Lurndal
 | |  ||     |         `- Re: Faking a TTY on a pipe/socketpairJim Jackson
 | |  ||     `* Re: Faking a TTY on a pipe/socketpairMuttley
 | |  ||      `* Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  ||       +* Re: Faking a TTY on a pipe/socketpairMuttley
 | |  ||       |`* Re: Faking a TTY on a pipe/socketpairJohn Ames
 | |  ||       | +* Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  ||       | |+* Re: Faking a TTY on a pipe/socketpairRainer Weikusat
 | |  ||       | ||`* Re: Faking a TTY on a pipe/socketpairMuttley
 | |  ||       | || `* Re: Faking a TTY on a pipe/socketpairRainer Weikusat
 | |  ||       | ||  `* Re: Faking a TTY on a pipe/socketpairMuttley
 | |  ||       | ||   `* Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  ||       | ||    +* Re: Faking a TTY on a pipe/socketpairMuttley
 | |  ||       | ||    |`- Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  ||       | ||    `- Re: Faking a TTY on a pipe/socketpairRainer Weikusat
 | |  ||       | |`* Re: Faking a TTY on a pipe/socketpairJohn Ames
 | |  ||       | | `* Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  ||       | |  +- Re: Faking a TTY on a pipe/socketpairJohn Ames
 | |  ||       | |  +* Re: Faking a TTY on a pipe/socketpairJim Jackson
 | |  ||       | |  |+* Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  ||       | |  ||`* Re: Faking a TTY on a pipe/socketpairMuttley
 | |  ||       | |  || `- Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  ||       | |  |`* Re: Faking a TTY on a pipe/socketpairRichard Kettlewell
 | |  ||       | |  | +* Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  ||       | |  | |`- Re: Faking a TTY on a pipe/socketpairKenny McCormack
 | |  ||       | |  | `- Re: Faking a TTY on a pipe/socketpairRainer Weikusat
 | |  ||       | |  `- Re: Faking a TTY on a pipe/socketpairRainer Weikusat
 | |  ||       | `- Re: Faking a TTY on a pipe/socketpairMuttley
 | |  ||       +- Re: Faking a TTY on a pipe/socketpairRainer Weikusat
 | |  ||       `- Re: Faking a TTY on a pipe/socketpairJim Jackson
 | |  |`* Re: Faking a TTY on a pipe/socketpairRichard L. Hamilton
 | |  | +- Re: Faking a TTY on a pipe/socketpairMuttley
 | |  | `- Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | |  `- Re: Faking a TTY on a pipe/socketpairLawrence D'Oliveiro
 | `* Re: Faking a TTY on a pipe/socketpairRichard L. Hamilton
 +- Re: Faking a TTY on a pipe/socketpairRichard Kettlewell
 `- Re: Faking a TTY on a pipe/socketpairScott Lurndal

Pages:12345
Subject: Faking a TTY on a pipe/socketpair
From: Muttley@dastardlyhq.com
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Sat, 16 Nov 2024 11:26 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Muttley@dastardlyhq.com
Newsgroups: comp.unix.programmer
Subject: Faking a TTY on a pipe/socketpair
Date: Sat, 16 Nov 2024 11:26:19 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <vh9vgr$5bb$1@dont-email.me>
Injection-Date: Sat, 16 Nov 2024 12:26:20 +0100 (CET)
Injection-Info: dont-email.me; posting-host="73359d0094adae4b4ea1cf9583bab7bb";
logging-data="5483"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/tw0wdVNYD1TcIzDrSFffe"
Cancel-Lock: sha1:hXxhcE+YeM46lPuhptsVyoUMIo4=
View all headers

There is a command line util (MacOS "say")* that I wish to use fork-exec'd from
my own program and send data to it via a socket created by socketpair().
Unfortunately "say" behaves differently depending on whether its stdin is
attached to a tty or not (and there's no cmd line option to prevent this).
With the former it'll speak after every newline, with the latter not until it
gets an EOF and I'd rather not do a fork-exec for each individual word or
phrase that needs to be spoken.

So my question is - is there a way to set up a pipe or socketpair** so that
it appears to be a tty from the exec'd programs point of view, eg ttyname()
returns non null?

* The MacOS speech API is Objective-C only and completely obtuse.

** Yes I know about the master-slave ptm,pts approach and I have done that in
the past but its complete overkill for this purpose.

Thanks for any help

Subject: Re: Faking a TTY on a pipe/socketpair
From: Kenny McCormack
Newsgroups: comp.unix.programmer
Organization: The official candy of the new Millennium
Date: Sat, 16 Nov 2024 20:51 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Sat, 16 Nov 2024 20:51:28 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vhb0kg$ih4k$1@news.xmission.com>
References: <vh9vgr$5bb$1@dont-email.me>
Injection-Date: Sat, 16 Nov 2024 20:51:28 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="607380"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <vh9vgr$5bb$1@dont-email.me>, <Muttley@dastardlyhq.com> wrote:
>There is a command line util (MacOS "say")* that I wish to use fork-exec'd from
>my own program and send data to it via a socket created by socketpair().
>Unfortunately "say" behaves differently depending on whether its stdin is
>attached to a tty or not (and there's no cmd line option to prevent this).
>With the former it'll speak after every newline, with the latter not until it
>gets an EOF and I'd rather not do a fork-exec for each individual word or
>phrase that needs to be spoken.
>
>So my question is - is there a way to set up a pipe or socketpair** so that
>it appears to be a tty from the exec'd programs point of view, eg ttyname()
>returns non null?

I think the short answer to your question is: No.

There's no way to directly do what you want in a clean way.

Thus, all we have is kludgey workarounds. And I'm sure you've got plenty
of your own kludgey workarounds; you don't need any more from me.

That said, if was me, I'd use Expect. A few lines of Expect would do it,
such that I could send text to the process and the process would think they
were coming from a tty. In fact, if you don't want to learn Expect (i.e.,
Tcl) just for this project, I think just using "unbuffer -p" (unbuffer is a
program that comes with the Expect distribution) would do it for you.

If you want a more integrated Expect solution, there is a way to embed
Expect inside of your C program (i.e., link to it as a DLL instead of via
TCL scripting). I've never done this because I've never had the need, but
it might be closer to what you want.

Another way might be to write an interposer so that you could fool the
"say" program into thinking it was talking to a tty even if it wasn't. I
haven't done any Mac programming in a long time (since my Mac stopped
working), but I think interposers were do-able in the Mac ecosystem.

--
Many North Koreans believe Kim-il-Sung is an "almighty god" who "created
the world" in seven days as a divine spirit millions of years ago, and
came to Earth as a human in 1912 as a messianic figure.

Subject: Re: Faking a TTY on a pipe/socketpair
From: Muttley@DastartdlyHQ.org
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Sun, 17 Nov 2024 08:41 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Muttley@DastartdlyHQ.org
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Sun, 17 Nov 2024 08:41:06 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <vhca72$i0nn$1@dont-email.me>
References: <vh9vgr$5bb$1@dont-email.me> <vhb0kg$ih4k$1@news.xmission.com>
Injection-Date: Sun, 17 Nov 2024 09:41:07 +0100 (CET)
Injection-Info: dont-email.me; posting-host="2f53b61dbe86a085a792d4535f0fa63e";
logging-data="590583"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18IyypxGdaTd+GUYH6o2GST"
Cancel-Lock: sha1:gmFkwjgUD9vLmGz8L/85Av2q3yI=
View all headers

On Sat, 16 Nov 2024 20:51:28 -0000 (UTC)
gazelle@shell.xmission.com (Kenny McCormack) boring babbled:
>In article <vh9vgr$5bb$1@dont-email.me>, <Muttley@dastardlyhq.com> wrote:
>>So my question is - is there a way to set up a pipe or socketpair** so that
>>it appears to be a tty from the exec'd programs point of view, eg ttyname()
>>returns non null?
>
>I think the short answer to your question is: No.
>
>There's no way to directly do what you want in a clean way.
>
>Thus, all we have is kludgey workarounds. And I'm sure you've got plenty
>of your own kludgey workarounds; you don't need any more from me.
>
>That said, if was me, I'd use Expect. A few lines of Expect would do it,
>such that I could send text to the process and the process would think they
>were coming from a tty. In fact, if you don't want to learn Expect (i.e.,
>Tcl) just for this project, I think just using "unbuffer -p" (unbuffer is a
>program that comes with the Expect distribution) would do it for you.

Hmm, both sound pretty kludgey too tbh. As for Tcl , thats a blast from the
past. Does anyone really still use it?

>Another way might be to write an interposer so that you could fool the
>"say" program into thinking it was talking to a tty even if it wasn't. I
>haven't done any Mac programming in a long time (since my Mac stopped
>working), but I think interposers were do-able in the Mac ecosystem.

Not heard of that. Probably simpler just to do master-slave pty stuff in
the end which I may well end up having to do.o

Kind of annoying the developers of "say" didn't consider this scenario. After
all , the whole point of having a command line speech utility is for it to
be controlled by another process, its not much use on its own other than
5 mins of novelty value!

Subject: Re: Faking a TTY on a pipe/socketpair
From: Wolfgang Agnes
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Sun, 17 Nov 2024 14:38 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: wagnes@example.com (Wolfgang Agnes)
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Sun, 17 Nov 2024 11:38:28 -0300
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <87a5dysz6j.fsf@example.com>
References: <vh9vgr$5bb$1@dont-email.me> <vhb0kg$ih4k$1@news.xmission.com>
<vhca72$i0nn$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sun, 17 Nov 2024 15:38:28 +0100 (CET)
Injection-Info: dont-email.me; posting-host="c039ffefe384255c105052bd57429333";
logging-data="725476"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/DFbUk9/bNzwFhxOAc42yW1+bg7GII9WI="
Cancel-Lock: sha1:VrwB0NbYHIhtMFoE3rBRCwrhJyM=
sha1:SNcXeI3qHoF+7GlObl8dqha7uPA=
View all headers

Muttley@DastartdlyHQ.org writes:

> On Sat, 16 Nov 2024 20:51:28 -0000 (UTC)
> gazelle@shell.xmission.com (Kenny McCormack) boring babbled:
>>In article <vh9vgr$5bb$1@dont-email.me>, <Muttley@dastardlyhq.com> wrote:
>>>So my question is - is there a way to set up a pipe or socketpair** so that
>>>it appears to be a tty from the exec'd programs point of view, eg ttyname()
>>>returns non null?
>>
>>I think the short answer to your question is: No.
>>
>>There's no way to directly do what you want in a clean way.
>>
>>Thus, all we have is kludgey workarounds. And I'm sure you've got plenty
>>of your own kludgey workarounds; you don't need any more from me.
>>
>>That said, if was me, I'd use Expect. A few lines of Expect would do it,
>>such that I could send text to the process and the process would think they
>>were coming from a tty. In fact, if you don't want to learn Expect (i.e.,
>>Tcl) just for this project, I think just using "unbuffer -p" (unbuffer is a
>>program that comes with the Expect distribution) would do it for you.
>
> Hmm, both sound pretty kludgey too tbh. As for Tcl , thats a blast from the
> past. Does anyone really still use it?

Hey, software doesn't dusty.

Subject: Re: Faking a TTY on a pipe/socketpair
From: Kaz Kylheku
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Sun, 17 Nov 2024 17:48 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Sun, 17 Nov 2024 17:48:23 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <20241117093714.675@kylheku.com>
References: <vh9vgr$5bb$1@dont-email.me>
Injection-Date: Sun, 17 Nov 2024 18:48:27 +0100 (CET)
Injection-Info: dont-email.me; posting-host="c8caec0720aa5c35cd0c3b5a0df22da9";
logging-data="798654"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+QTE0DRh7UzyreVsaAhCcyKipQAc1ZDzc="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:zja3No8rlI5sB5Ridfo4ZO7KElQ=
View all headers

On 2024-11-16, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
> So my question is - is there a way to set up a pipe or socketpair** so that
> it appears to be a tty from the exec'd programs point of view, eg ttyname()
> returns non null?
[...]
> ** Yes I know about the master-slave ptm,pts approach and I have done that in
> the past but its complete overkill for this purpose.

No; you need a master/slave pseudo TTY pair connected to an active
process, which forwards between that and the socketpair or pipe.

Sockets and pipes cannot be given window dressing so that they look
like tty's. When the standard input (or output) of a process is a tty,
and that process cares about it, it will likely try operations like
tcgetattr.

Programs that use stdio standard input are affected by whether the
output is a TTY or not because the standard libraries on Unixes call
isatty() to determine whether the input constitutes an "interactive
device" according to ISO C, and hence whether to make the output fully
buffered.

The GNU C Library has a mechanism to override this, driven by
environment variables, and a wrapper utility callet "stdbuf"
which uses the environment variables to tell a child process
what buffering discipline to use for stdin, stdour or stderr.

So for that one small way in which it matters whether the standard
input or output is a TTY, at least one platform has a solution:
you don't have to fake out a TTY to trick a program into stdout
or stderr line buffering.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Subject: Re: Faking a TTY on a pipe/socketpair
From: Kenny McCormack
Newsgroups: comp.unix.programmer
Organization: The official candy of the new Millennium
Date: Sun, 17 Nov 2024 18:25 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Sun, 17 Nov 2024 18:25:28 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <vhdceo$jl4t$1@news.xmission.com>
References: <vh9vgr$5bb$1@dont-email.me> <vhb0kg$ih4k$1@news.xmission.com> <vhca72$i0nn$1@dont-email.me>
Injection-Date: Sun, 17 Nov 2024 18:25:28 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="644253"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <vhca72$i0nn$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote:
....
>Kind of annoying the developers of "say" didn't consider this scenario. After
>all , the whole point of having a command line speech utility is for it to
>be controlled by another process, its not much use on its own other than
>5 mins of novelty value!

I assume that their intent is that if you are doing anything remotely
serious, you will use their API. The "say" program was probably a 15 minute
effort by whoever developed the API; I doubt much thought went into it
other than as a quick "proof of concept".

Yes, things like this are annoying.

--
If the automobile had followed the same development cycle as the
computer, a Rolls-Royce today would cost $100, get a million miles to
the gallon, and explode once every few weeks, killing everyone inside.

Subject: Re: Faking a TTY on a pipe/socketpair
From: Muttley@DastartdlyHQ.org
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Sun, 17 Nov 2024 18:39 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Muttley@DastartdlyHQ.org
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Sun, 17 Nov 2024 18:39:16 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <vhdd8k$p4na$1@dont-email.me>
References: <vh9vgr$5bb$1@dont-email.me> <20241117093714.675@kylheku.com>
Injection-Date: Sun, 17 Nov 2024 19:39:17 +0100 (CET)
Injection-Info: dont-email.me; posting-host="2f53b61dbe86a085a792d4535f0fa63e";
logging-data="824042"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX199lHsZDEvGvJPkyDHVg6qN"
Cancel-Lock: sha1:XCC/+/15fhOiG8cG+BAHZHKbRMo=
View all headers

On Sun, 17 Nov 2024 17:48:23 -0000 (UTC)
Kaz Kylheku <643-408-1753@kylheku.com> boring babbled:
>On 2024-11-16, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
>> So my question is - is there a way to set up a pipe or socketpair** so that
>> it appears to be a tty from the exec'd programs point of view, eg ttyname()
>> returns non null?
>[...]
>> ** Yes I know about the master-slave ptm,pts approach and I have done that
>in
>> the past but its complete overkill for this purpose.
>
>No; you need a master/slave pseudo TTY pair connected to an active
>process, which forwards between that and the socketpair or pipe.

I figured as much but thought I'd ask, you never know.

>Sockets and pipes cannot be given window dressing so that they look
>like tty's. When the standard input (or output) of a process is a tty,
>and that process cares about it, it will likely try operations like
>tcgetattr.

The only think I suspect this util cares about is whether its having a file
redirected into its stdin and uses isatty() to find out. Its behaviour when
injesting a file is to take it all in the speak the lot instead of line by
line. Why I don't know, it would make little to no difference to the output.

Subject: Re: Faking a TTY on a pipe/socketpair
From: Muttley@DastartdlyHQ.org
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Sun, 17 Nov 2024 18:41 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Muttley@DastartdlyHQ.org
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Sun, 17 Nov 2024 18:41:59 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <vhdddn$p60t$1@dont-email.me>
References: <vh9vgr$5bb$1@dont-email.me> <vhb0kg$ih4k$1@news.xmission.com> <vhca72$i0nn$1@dont-email.me> <vhdceo$jl4t$1@news.xmission.com>
Injection-Date: Sun, 17 Nov 2024 19:41:59 +0100 (CET)
Injection-Info: dont-email.me; posting-host="2f53b61dbe86a085a792d4535f0fa63e";
logging-data="825373"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+x0V+RDLobOVcjsfkh5/Q6"
Cancel-Lock: sha1:llbpmb4E+vhKdfarw/qMgXvbvug=
View all headers

On Sun, 17 Nov 2024 18:25:28 -0000 (UTC)
gazelle@shell.xmission.com (Kenny McCormack) boring babbled:
>In article <vhca72$i0nn$1@dont-email.me>, <Muttley@DastartdlyHQ.org> wrote:
>....
>>Kind of annoying the developers of "say" didn't consider this scenario. After
>>all , the whole point of having a command line speech utility is for it to
>>be controlled by another process, its not much use on its own other than
>>5 mins of novelty value!
>
>I assume that their intent is that if you are doing anything remotely
>serious, you will use their API. The "say" program was probably a 15 minute

Quite possibly. Unfortunately apart from core Posix and a few system APIs, all
MacOS APIs these days are Objective-C (and swift), a language few people know
and few - including myself - have the time or inclination to learn given the
amount I'd ever use it.

>effort by whoever developed the API; I doubt much thought went into it
>other than as a quick "proof of concept".

It seems fairly comprehensive tbh.

Subject: Re: Faking a TTY on a pipe/socketpair
From: Janis Papanagnou
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Mon, 18 Nov 2024 02:38 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Mon, 18 Nov 2024 03:38:01 +0100
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <vhe9aa$ufh7$1@dont-email.me>
References: <vh9vgr$5bb$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 18 Nov 2024 03:38:02 +0100 (CET)
Injection-Info: dont-email.me; posting-host="da8dc5b53507b46ac4f1202689067d91";
logging-data="998951"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ZB8uh9RKbS+7fouov5MeS"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:a7DHyobQzW8CcID6+tGpDIX+MwM=
In-Reply-To: <vh9vgr$5bb$1@dont-email.me>
Content-Language: en-US
View all headers

On 16.11.24 12:26, Muttley@dastardlyhq.com wrote:
> There is a command line util (MacOS "say")* that I wish to use fork-exec'd from
> my own program and send data to it via a socket created by socketpair().
> Unfortunately "say" behaves differently depending on whether its stdin is
> attached to a tty or not (and there's no cmd line option to prevent this).
> With the former it'll speak after every newline, with the latter not until it
> gets an EOF and I'd rather not do a fork-exec for each individual word or
> phrase that needs to be spoken.

On shell level I'm using a program called 'pty' that takes the command
as argument to make it think it has a terminal connection. Say, instead
of calling (forking) your 'say' command you're calling (forking) the
'pty' command with your 'say' command provided as argument. And all the
gory details are kept inside the 'pty'. - I forgot whether 'pty' came
with my Linux system, or whether I downloaded it separately, or whether
I implemented or adapted the version that is published in Stevens' APUE
book (with the source code available online, IIRC). IME it's worthwhile
to have such a tool at hand; it's useful to me for various application
contexts, and the interface is clean, a separate small tool unnecessary
to be merged on source code level, and simple to use.

I've just tried it (on shell level)... (less than 2 minutes effort...)
* Download the APUE examples: http://www.apuebook.com/src.3e.tar.gz
* Enter the pty directory and call "make" to get the 'pty' program
* To test it try, e.g.: "ls", "ls | cat -", and, "./pty ls | cat -"

Disclaimer: I have used 'pty' from shell only, but given what I faintly
recall from the mechanisms documented in Stevens' book I'd expect it to
work transparently also from a fork/exec'ed pipe-connected context.
If you'll try it I'd be interested in feedback, how/whether it works in
your fork/exec context with 'say'.

Janis

>
> So my question is - is there a way to set up a pipe or socketpair** so that
> it appears to be a tty from the exec'd programs point of view, eg ttyname()
> returns non null?
>
> * The MacOS speech API is Objective-C only and completely obtuse.
>
> ** Yes I know about the master-slave ptm,pts approach and I have done that in
> the past but its complete overkill for this purpose.
>
> Thanks for any help
>
>

Subject: Re: Faking a TTY on a pipe/socketpair
From: Muttley@DastartdlyHQ.org
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Mon, 18 Nov 2024 08:26 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Muttley@DastartdlyHQ.org
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Mon, 18 Nov 2024 08:26:48 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <vheto8$15ghr$1@dont-email.me>
References: <vh9vgr$5bb$1@dont-email.me> <vhe9aa$ufh7$1@dont-email.me>
Injection-Date: Mon, 18 Nov 2024 09:26:49 +0100 (CET)
Injection-Info: dont-email.me; posting-host="a13039780296c44b29e5aa9b4bf19c94";
logging-data="1229371"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19l6Pi2DdLyRX0bQRWErosw"
Cancel-Lock: sha1:JcY+63G7G3eI0JeVIYFW1cPShJI=
View all headers

On Mon, 18 Nov 2024 03:38:01 +0100
Janis Papanagnou <janis_papanagnou@hotmail.com> boring babbled:
>On 16.11.24 12:26, Muttley@dastardlyhq.com wrote:
>> There is a command line util (MacOS "say")* that I wish to use fork-exec'd
>from
>> my own program and send data to it via a socket created by socketpair().
>> Unfortunately "say" behaves differently depending on whether its stdin is
>> attached to a tty or not (and there's no cmd line option to prevent this).
>> With the former it'll speak after every newline, with the latter not until it
>
>> gets an EOF and I'd rather not do a fork-exec for each individual word or
>> phrase that needs to be spoken.
>
>On shell level I'm using a program called 'pty' that takes the command
>as argument to make it think it has a terminal connection. Say, instead
>of calling (forking) your 'say' command you're calling (forking) the
>'pty' command with your 'say' command provided as argument. And all the
>gory details are kept inside the 'pty'. - I forgot whether 'pty' came
>with my Linux system, or whether I downloaded it separately, or whether
>I implemented or adapted the version that is published in Stevens' APUE
>book (with the source code available online, IIRC). IME it's worthwhile
>to have such a tool at hand; it's useful to me for various application
>contexts, and the interface is clean, a separate small tool unnecessary
>to be merged on source code level, and simple to use.

Unfortunately I can't find an equivalent to the pty util on MacOS.

Subject: Re: Faking a TTY on a pipe/socketpair
From: Richard Kettlewell
Newsgroups: comp.unix.programmer
Organization: terraraq NNTP server
Date: Mon, 18 Nov 2024 09:51 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: invalid@invalid.invalid (Richard Kettlewell)
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Mon, 18 Nov 2024 09:51:33 +0000
Organization: terraraq NNTP server
Message-ID: <wwvy11ghntm.fsf@LkoBDZeT.terraraq.uk>
References: <vh9vgr$5bb$1@dont-email.me> <vhe9aa$ufh7$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
logging-data="10281"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:2uQu+rpsPOQ/HWmDokjfEnH2z8s=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
View all headers

Janis Papanagnou <janis_papanagnou@hotmail.com> writes:
> On 16.11.24 12:26, Muttley@dastardlyhq.com wrote:
>> There is a command line util (MacOS "say")* that I wish to use
>> fork-exec'd from
>> my own program and send data to it via a socket created by socketpair().
>> Unfortunately "say" behaves differently depending on whether its stdin is
>> attached to a tty or not (and there's no cmd line option to prevent this).
>> With the former it'll speak after every newline, with the latter not until it
>> gets an EOF and I'd rather not do a fork-exec for each individual word or
>> phrase that needs to be spoken.
>
> On shell level I'm using a program called 'pty' that takes the command
> as argument to make it think it has a terminal connection.

‘script’ will do the same and already exists on macOS. It likes to write
stdout/stderr to a file as well as its own otuput, but you can use
/dev/null for that.

I had some trouble getting it to play fully nicely with say, but some
fiddling might get the desired effect.

--
https://www.greenend.org.uk/rjk/

Subject: Re: Faking a TTY on a pipe/socketpair
From: Muttley@DastartdlyHQ.org
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Mon, 18 Nov 2024 09:57 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Muttley@DastartdlyHQ.org
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Mon, 18 Nov 2024 09:57:12 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <vhf31o$16eui$1@dont-email.me>
References: <vh9vgr$5bb$1@dont-email.me> <vhe9aa$ufh7$1@dont-email.me> <wwvy11ghntm.fsf@LkoBDZeT.terraraq.uk>
Injection-Date: Mon, 18 Nov 2024 10:57:12 +0100 (CET)
Injection-Info: dont-email.me; posting-host="a13039780296c44b29e5aa9b4bf19c94";
logging-data="1260498"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/AmxsZKhuQG6VoUGWWJIqz"
Cancel-Lock: sha1:AnoZ7cy9YWb3ZGxH8EMli24rivI=
View all headers

On Mon, 18 Nov 2024 09:51:33 +0000
Richard Kettlewell <invalid@invalid.invalid> boring babbled:
>Janis Papanagnou <janis_papanagnou@hotmail.com> writes:
>> On 16.11.24 12:26, Muttley@dastardlyhq.com wrote:
>>> There is a command line util (MacOS "say")* that I wish to use
>>> fork-exec'd from
>>> my own program and send data to it via a socket created by socketpair().
>>> Unfortunately "say" behaves differently depending on whether its stdin is
>>> attached to a tty or not (and there's no cmd line option to prevent this).
>>> With the former it'll speak after every newline, with the latter not until
>it
>>> gets an EOF and I'd rather not do a fork-exec for each individual word or
>>> phrase that needs to be spoken.
>>
>> On shell level I'm using a program called 'pty' that takes the command
>> as argument to make it think it has a terminal connection.
>
>‘script’ will do the same and already exists on macOS. It likes to write
>stdout/stderr to a file as well as its own otuput, but you can use
>/dev/null for that.
>
>I had some trouble getting it to play fully nicely with say, but some
>fiddling might get the desired effect.

Sounds a little bit hacky but I'll have a look at it, cheers.

Subject: Re: Faking a TTY on a pipe/socketpair
From: Eric Pozharski
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Mon, 18 Nov 2024 07:54 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: apple.universe@posteo.net (Eric Pozharski)
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Mon, 18 Nov 2024 07:54:22 +0000
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <slrnvjlsle.s3j.apple.universe@freight.zombinet>
References: <vh9vgr$5bb$1@dont-email.me> <20241117093714.675@kylheku.com>
Injection-Date: Mon, 18 Nov 2024 11:33:07 +0100 (CET)
Injection-Info: dont-email.me; posting-host="61ccd69ef92e0816b2329558c0164158";
logging-data="1273450"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19cSfuSbps1fRo+5S0MaafK"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:6L0Ztw0VARs1jyiTAbzv3YHLh0M=
View all headers

with <20241117093714.675@kylheku.com> Kaz Kylheku wrote:
> On 2024-11-16, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:

>> So my question is - is there a way to set up a pipe or socketpair**
>> so that it appears to be a tty from the exec'd programs point of
>> view, eg ttyname() returns non null?
*SKIP* [ 18 lines 2 levels deep]
> The GNU C Library has a mechanism to override this, driven by
> environment variables, and a wrapper utility callet "stdbuf" which
> uses the environment variables to tell a child process what buffering
> discipline to use for stdin, stdour or stderr.

Now I understand what's going on (back then I've come to conclusions and
called names (AKA -- I'd been pissed off by 9 out of 12); I was
wrong). But variables? Neither stdbuf(1) nor setbuf(3) give any
directions. What should I read?

*CUT* [ 6 lines 1 level deep]

--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom

Subject: Re: Faking a TTY on a pipe/socketpair
From: Scott Lurndal
Newsgroups: comp.unix.programmer
Organization: UsenetServer - www.usenetserver.com
Date: Mon, 18 Nov 2024 14:02 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!feeder2.eternal-september.org!news.quux.org!weretis.net!feeder9.news.weretis.net!newsfeed.hasname.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx10.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Faking a TTY on a pipe/socketpair
Newsgroups: comp.unix.programmer
References: <vh9vgr$5bb$1@dont-email.me> <20241117093714.675@kylheku.com> <slrnvjlsle.s3j.apple.universe@freight.zombinet>
Lines: 21
Message-ID: <4OH_O.18405$OVd1.10863@fx10.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Mon, 18 Nov 2024 14:02:40 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Mon, 18 Nov 2024 14:02:40 GMT
X-Received-Bytes: 1710
View all headers

Eric Pozharski <apple.universe@posteo.net> writes:
>with <20241117093714.675@kylheku.com> Kaz Kylheku wrote:
>> On 2024-11-16, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
>
>>> So my question is - is there a way to set up a pipe or socketpair**
>>> so that it appears to be a tty from the exec'd programs point of
>>> view, eg ttyname() returns non null?
>*SKIP* [ 18 lines 2 levels deep]
>> The GNU C Library has a mechanism to override this, driven by
>> environment variables, and a wrapper utility callet "stdbuf" which
>> uses the environment variables to tell a child process what buffering
>> discipline to use for stdin, stdour or stderr.
>
>Now I understand what's going on (back then I've come to conclusions and
>called names (AKA -- I'd been pissed off by 9 out of 12); I was
>wrong). But variables? Neither stdbuf(1) nor setbuf(3) give any
>directions. What should I read?

About 45 seconds of google search resulted in "GLIBC_TUNABLES".

https://www.gnu.org/software/libc/manual/html_node/Tunables.html

Subject: Re: Faking a TTY on a pipe/socketpair
From: Kaz Kylheku
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Mon, 18 Nov 2024 20:43 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Mon, 18 Nov 2024 20:43:41 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <20241118123754.282@kylheku.com>
References: <vh9vgr$5bb$1@dont-email.me> <20241117093714.675@kylheku.com>
<slrnvjlsle.s3j.apple.universe@freight.zombinet>
Injection-Date: Mon, 18 Nov 2024 21:43:41 +0100 (CET)
Injection-Info: dont-email.me; posting-host="6db7747279c40d35515ba07bc9abcef1";
logging-data="1501488"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Rl5cAhxjH3UKjFRm0rKp4FqkVKhIoS90="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:V0dC+qejSo2WBhM/vKRM+dJ+ecg=
View all headers

On 2024-11-18, Eric Pozharski <apple.universe@posteo.net> wrote:
> with <20241117093714.675@kylheku.com> Kaz Kylheku wrote:
>> On 2024-11-16, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com> wrote:
>
>>> So my question is - is there a way to set up a pipe or socketpair**
>>> so that it appears to be a tty from the exec'd programs point of
>>> view, eg ttyname() returns non null?
> *SKIP* [ 18 lines 2 levels deep]
>> The GNU C Library has a mechanism to override this, driven by
>> environment variables, and a wrapper utility callet "stdbuf" which
>> uses the environment variables to tell a child process what buffering
>> discipline to use for stdin, stdour or stderr.
>
> Now I understand what's going on (back then I've come to conclusions and
> called names (AKA -- I'd been pissed off by 9 out of 12); I was
> wrong). But variables? Neither stdbuf(1) nor setbuf(3) give any
> directions. What should I read?

Firstly, I apologize for my bad here, Eric. This is not done in glibc,
but actually by a preloaded shared library called libstdbuf.so. That
comes from CoreUtils.

I'm not sure where/if the environment variables are documented.

To simulate the action of stdbuf in your own program, you need
to LD_PRELOAD libstdbuf, and set the environment variables,
then execute the target program.

See the files src/stdbuf.c and src/libstdbuf.c in the GNU Coreutils
tree.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Subject: Re: Faking a TTY on a pipe/socketpair
From: Eric Pozharski
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Tue, 19 Nov 2024 10:07 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: apple.universe@posteo.net (Eric Pozharski)
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Tue, 19 Nov 2024 10:07:10 +0000
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <slrnvjooqe.ois.apple.universe@freight.zombinet>
References: <vh9vgr$5bb$1@dont-email.me> <20241117093714.675@kylheku.com>
<slrnvjlsle.s3j.apple.universe@freight.zombinet>
<20241118123754.282@kylheku.com>
Injection-Date: Tue, 19 Nov 2024 11:33:08 +0100 (CET)
Injection-Info: dont-email.me; posting-host="3dce06738035c6d7b440dfadbfa7c796";
logging-data="1896306"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19xgMY1VmD8AsOZKWT/inHm"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:RerSGNwZoNUsoI7MhUZTHiZiGbs=
View all headers

with <20241118123754.282@kylheku.com> Kaz Kylheku wrote:
> On 2024-11-18, Eric Pozharski <apple.universe@posteo.net> wrote:
>> with <20241117093714.675@kylheku.com> Kaz Kylheku wrote:
>>> On 2024-11-16, Muttley@dastardlyhq.com <Muttley@dastardlyhq.com>
>>> wrote:

>>>> So my question is - is there a way to set up a pipe or socketpair**
>>>> so that it appears to be a tty from the exec'd programs point of
>>>> view, eg ttyname() returns non null?
>> *SKIP* [ 18 lines 2 levels deep]
>>> The GNU C Library has a mechanism to override this, driven by
>>> environment variables, and a wrapper utility callet "stdbuf" which
>>> uses the environment variables to tell a child process what
>>> buffering discipline to use for stdin, stdour or stderr.
>> Now I understand what's going on (back then I've come to conclusions
*SKIP* [ 2 lines 2 levels deep]
>> directions. What should I read?
> Firstly, I apologize for my bad here, Eric. This is not done in glibc,
> but actually by a preloaded shared library called libstdbuf.so. That
> comes from CoreUtils.

Well, stdbuf(1) is good enough then.

*CUT* [ 9 lines 1 level deep]

--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom

Subject: Re: Faking a TTY on a pipe/socketpair
From: Richard L. Hamilton
Newsgroups: comp.unix.programmer
Organization: Timetravellers Anonymous
Date: Tue, 3 Dec 2024 05:29 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx17.iad.POSTED!not-for-mail
Mime-Version: 1.0
X-Newsreader: knews 1.0b.1
Reply-To: rlhamil@smart.net
Organization: Timetravellers Anonymous
References: <vh9vgr$5bb$1@dont-email.me>
From: rlhamil@smart.net (Richard L. Hamilton)
Subject: Re: Faking a TTY on a pipe/socketpair
Newsgroups: comp.unix.programmer
Content-Type: text/plain; charset=us-ascii
Lines: 28
Message-ID: <jHw3P.41603$vLg2.41154@fx17.iad>
X-Complaints-To: abuse(at)newshosting.com
NNTP-Posting-Date: Tue, 03 Dec 2024 05:29:51 UTC
Date: Tue, 03 Dec 2024 05:29:51 GMT
X-Received-Bytes: 1871
View all headers

In article <vh9vgr$5bb$1@dont-email.me>,
Muttley@dastardlyhq.com writes:
> There is a command line util (MacOS "say")* that I wish to use fork-exec'd from
> my own program and send data to it via a socket created by socketpair().
> Unfortunately "say" behaves differently depending on whether its stdin is
> attached to a tty or not (and there's no cmd line option to prevent this).
> With the former it'll speak after every newline, with the latter not until it
> gets an EOF and I'd rather not do a fork-exec for each individual word or
> phrase that needs to be spoken.
>
> So my question is - is there a way to set up a pipe or socketpair** so that
> it appears to be a tty from the exec'd programs point of view, eg ttyname()
> returns non null?
>
> * The MacOS speech API is Objective-C only and completely obtuse.
>
> ** Yes I know about the master-slave ptm,pts approach and I have done that in
> the past but its complete overkill for this purpose.
>
> Thanks for any help
>
>

Not on a Mac. Use "expect" which does the pts/pty stuff for you.

(on a system where pipes are STREAMS based, it might be possible
to come up with a module that made a pipe pretend on one side to be a tty;
but you'd have to get into some nasty kernel coding to do that)

Subject: Re: Faking a TTY on a pipe/socketpair
From: Muttley@DastardlyHQ.org
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Tue, 3 Dec 2024 08:20 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Muttley@DastardlyHQ.org
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Tue, 3 Dec 2024 08:20:51 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <vimf13$3uoji$1@dont-email.me>
References: <vh9vgr$5bb$1@dont-email.me> <jHw3P.41603$vLg2.41154@fx17.iad>
Injection-Date: Tue, 03 Dec 2024 09:20:51 +0100 (CET)
Injection-Info: dont-email.me; posting-host="fbae6200e75959e315b1e5a231ba8e36";
logging-data="4153970"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++D6OkX6vbqZ9us5N0McMN"
Cancel-Lock: sha1:OLaU2A5D5Cf1VWs8zZ75qL2EKuI=
View all headers

On Tue, 03 Dec 2024 05:29:51 GMT
rlhamil@smart.net (Richard L. Hamilton) wibbled:
>In article <vh9vgr$5bb$1@dont-email.me>,
> Muttley@dastardlyhq.com writes:
>> There is a command line util (MacOS "say")* that I wish to use fork-exec'd
>from
>> my own program and send data to it via a socket created by socketpair().
>> Unfortunately "say" behaves differently depending on whether its stdin is
>> attached to a tty or not (and there's no cmd line option to prevent this).
>> With the former it'll speak after every newline, with the latter not until
>it
>> gets an EOF and I'd rather not do a fork-exec for each individual word or
>> phrase that needs to be spoken.
>>
>> So my question is - is there a way to set up a pipe or socketpair** so that
>> it appears to be a tty from the exec'd programs point of view, eg ttyname()
>> returns non null?
>>
>> * The MacOS speech API is Objective-C only and completely obtuse.
>>
>> ** Yes I know about the master-slave ptm,pts approach and I have done that
>in
>> the past but its complete overkill for this purpose.
>>
>> Thanks for any help
>>
>>
>
>Not on a Mac. Use "expect" which does the pts/pty stuff for you.
>
>(on a system where pipes are STREAMS based, it might be possible
>to come up with a module that made a pipe pretend on one side to be a tty;
>but you'd have to get into some nasty kernel coding to do that)

I'm wondering on Linux if it would be enough on Linux to spoof ttyname() and
isatty() using LD_PRELOAD. However it seems doing something similar on a Mac
is the usual over complicated Apple hot mess.

Subject: Re: Faking a TTY on a pipe/socketpair
From: Richard Kettlewell
Newsgroups: comp.unix.programmer
Organization: terraraq NNTP server
Date: Tue, 3 Dec 2024 08:38 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!news.gegeweb.eu!gegeweb.org!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: invalid@invalid.invalid (Richard Kettlewell)
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Tue, 03 Dec 2024 08:38:09 +0000
Organization: terraraq NNTP server
Message-ID: <wwvbjxtrwjy.fsf@LkoBDZeT.terraraq.uk>
References: <vh9vgr$5bb$1@dont-email.me> <jHw3P.41603$vLg2.41154@fx17.iad>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
logging-data="32687"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:ERG5KZBH8B8whS7eo9VRvWc2vmk=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
View all headers

rlhamil@smart.net (Richard L. Hamilton) writes:
> (on a system where pipes are STREAMS based, it might be possible to
> come up with a module that made a pipe pretend on one side to be a
> tty; but you'd have to get into some nasty kernel coding to do that)

That seems like more work than just using a pty, which the OP already
ruled out.

--
https://www.greenend.org.uk/rjk/

Subject: Re: Faking a TTY on a pipe/socketpair
From: Scott Lurndal
Newsgroups: comp.unix.programmer
Organization: UsenetServer - www.usenetserver.com
Date: Tue, 3 Dec 2024 14:22 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!border-1.nntp.ord.giganews.com!nntp.giganews.com!news-out.netnews.com!s1-1.netnews.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx11.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: scott@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Faking a TTY on a pipe/socketpair
Newsgroups: comp.unix.programmer
References: <vh9vgr$5bb$1@dont-email.me> <jHw3P.41603$vLg2.41154@fx17.iad>
Lines: 32
Message-ID: <muE3P.30620$Tx18.29536@fx11.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Tue, 03 Dec 2024 14:22:10 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Tue, 03 Dec 2024 14:22:10 GMT
X-Received-Bytes: 2081
X-Original-Bytes: 2030
View all headers

rlhamil@smart.net (Richard L. Hamilton) writes:
>In article <vh9vgr$5bb$1@dont-email.me>,
> Muttley@dastardlyhq.com writes:
>> There is a command line util (MacOS "say")* that I wish to use fork-exec'd from
>> my own program and send data to it via a socket created by socketpair().
>> Unfortunately "say" behaves differently depending on whether its stdin is
>> attached to a tty or not (and there's no cmd line option to prevent this).
>> With the former it'll speak after every newline, with the latter not until it
>> gets an EOF and I'd rather not do a fork-exec for each individual word or
>> phrase that needs to be spoken.
>>
>> So my question is - is there a way to set up a pipe or socketpair** so that
>> it appears to be a tty from the exec'd programs point of view, eg ttyname()
>> returns non null?
>>
>> * The MacOS speech API is Objective-C only and completely obtuse.
>>
>> ** Yes I know about the master-slave ptm,pts approach and I have done that in
>> the past but its complete overkill for this purpose.
>>
>> Thanks for any help
>>
>>
>
>Not on a Mac. Use "expect" which does the pts/pty stuff for you.
>
>(on a system where pipes are STREAMS based, it might be possible
>to come up with a module that made a pipe pretend on one side to be a tty;
>but you'd have to get into some nasty kernel coding to do that)

SVR4.2 included the 'strtty' streams module to support similar
scenarios, if I recall correctly.

Subject: Re: Faking a TTY on a pipe/socketpair
From: Lawrence D'Oliv
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Tue, 3 Dec 2024 20:21 UTC
References: 1 2 3
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Tue, 3 Dec 2024 20:21:27 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <vinp86$avd9$1@dont-email.me>
References: <vh9vgr$5bb$1@dont-email.me> <jHw3P.41603$vLg2.41154@fx17.iad>
<vimf13$3uoji$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 03 Dec 2024 21:21:27 +0100 (CET)
Injection-Info: dont-email.me; posting-host="c96be26192a45ce8d8c08f341d719685";
logging-data="359849"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/eaEFdNtN/mnJ/MV3dDgXA"
User-Agent: Pan/0.161 (Chasiv Yar; )
Cancel-Lock: sha1:uEht+pPzdqJNo3zHjAclUT9VYeo=
View all headers

On Tue, 3 Dec 2024 08:20:51 -0000 (UTC), Muttley wrote:

> I'm wondering on Linux if it would be enough on Linux to spoof ttyname()
> and isatty() using LD_PRELOAD. However it seems doing something similar
> on a Mac is the usual over complicated Apple hot mess.

macOS may be a licensee of the “Unix” trademark, but it does not work the
way people expect when they think of the term “Unix”.

Subject: Re: Faking a TTY on a pipe/socketpair
From: Muttley@DastardlyHQ.org
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Wed, 4 Dec 2024 08:34 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Muttley@DastardlyHQ.org
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Wed, 4 Dec 2024 08:34:30 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <vip46l$omqu$1@dont-email.me>
References: <vh9vgr$5bb$1@dont-email.me> <jHw3P.41603$vLg2.41154@fx17.iad>
<vimf13$3uoji$1@dont-email.me>
<vinp86$avd9$1@dont-email.me>
Injection-Date: Wed, 04 Dec 2024 09:34:30 +0100 (CET)
Injection-Info: dont-email.me; posting-host="8479bf124903116a480ba2aecb4d47c5";
logging-data="809822"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18n7IXl7p5tnCkLu9lzL+Kb"
Cancel-Lock: sha1:AZ/xFt6rsSD+jsn5zAELoTf7eUs=
View all headers

On Tue, 3 Dec 2024 20:21:27 -0000 (UTC)
Lawrence D'Oliveiro <ldo@nz.invalid> wibbled:
>On Tue, 3 Dec 2024 08:20:51 -0000 (UTC), Muttley wrote:
>
>> I'm wondering on Linux if it would be enough on Linux to spoof ttyname()
>> and isatty() using LD_PRELOAD. However it seems doing something similar
>> on a Mac is the usual over complicated Apple hot mess.
>
>macOS may be a licensee of the “Unix” trademark, but it does not work the
>way people expect when they think of the term “Unix”.

Yes, it certainly has its quirks. Linux is far closer to the unix philosphy
(ignoring systemd) despite not being an official unix.

Subject: Re: Faking a TTY on a pipe/socketpair
From: Lawrence D'Oliv
Newsgroups: comp.unix.programmer
Organization: A noiseless patient Spider
Date: Thu, 5 Dec 2024 02:11 UTC
References: 1 2 3 4 5
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Thu, 5 Dec 2024 02:11:04 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 5
Message-ID: <vir23n$17csf$5@dont-email.me>
References: <vh9vgr$5bb$1@dont-email.me> <jHw3P.41603$vLg2.41154@fx17.iad>
<vimf13$3uoji$1@dont-email.me> <vinp86$avd9$1@dont-email.me>
<vip46l$omqu$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 05 Dec 2024 03:11:04 +0100 (CET)
Injection-Info: dont-email.me; posting-host="b8ada25e4317f2ac3fdfff6f2c3be1a9";
logging-data="1291151"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+wF7BUYB7oM454dn4QUmWZ"
User-Agent: Pan/0.161 (Chasiv Yar; )
Cancel-Lock: sha1:Wxug1VzOH+Jxb7a++YUJUEqm/2E=
View all headers

On Wed, 4 Dec 2024 08:34:30 -0000 (UTC), Muttley wrote:

> Linux is far closer to the unix philosphy (ignoring systemd) ...

Which “unix philosophy” would that be?

Subject: Re: Faking a TTY on a pipe/socketpair
From: Kenny McCormack
Newsgroups: comp.unix.programmer
Organization: The official candy of the new Millennium
Date: Thu, 5 Dec 2024 06:44 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gazelle@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.programmer
Subject: Re: Faking a TTY on a pipe/socketpair
Date: Thu, 5 Dec 2024 06:44:12 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <viri3s$1ac00$1@news.xmission.com>
References: <vh9vgr$5bb$1@dont-email.me> <vinp86$avd9$1@dont-email.me> <vip46l$omqu$1@dont-email.me> <vir23n$17csf$5@dont-email.me>
Injection-Date: Thu, 5 Dec 2024 06:44:12 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1388544"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
View all headers

In article <vir23n$17csf$5@dont-email.me>,
Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>On Wed, 4 Dec 2024 08:34:30 -0000 (UTC), Muttley wrote:
>
>> Linux is far closer to the unix philosphy (ignoring systemd) ...
>
>Which "unix philosophy" would that be?

Wouldn't it be easier to just use Google (or whatever search engine you
favor) to find out what the Unix philosphy is?

--
Debating creationists on the topic of evolution is rather like trying to
play chess with a pigeon --- it knocks the pieces over, craps on the
board, and flies back to its flock to claim victory.

Subject: Re: Faking a TTY on a pipe/socketpair
From: Nicolas George
Newsgroups: comp.unix.programmer
Organization: Guest of ProXad - France
Date: Thu, 5 Dec 2024 08:01 UTC
References: 1 2 3 4 5 6
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!cleanfeed3-a.proxad.net!nnrp2-2.free.fr!not-for-mail
Newsgroups: comp.unix.programmer
From: nicolas$george@salle-s.org (Nicolas George)
Subject: Re: Faking a TTY on a pipe/socketpair
Sender: george@phare.invalid (Nicolas George)
X-Newsreader: Flrn (0.9.20070704)
References: <vh9vgr$5bb$1@dont-email.me> <jHw3P.41603$vLg2.41154@fx17.iad> <vimf13$3uoji$1@dont-email.me> <vinp86$avd9$1@dont-email.me> <vip46l$omqu$1@dont-email.me> <vir23n$17csf$5@dont-email.me>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=utf-8
Date: 05 Dec 2024 08:01:03 GMT
Lines: 6
Message-ID: <67515dbf$0$404$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 05 Dec 2024 09:01:03 CET
NNTP-Posting-Host: 129.199.129.80
X-Trace: 1733385663 news-3.free.fr 404 129.199.129.80:47020
X-Complaints-To: abuse@proxad.net
View all headers

Lawrence D'Oliveiro , dans le message <vir23n$17csf$5@dont-email.me>, a
écrit :
> Which “unix philosophy” would that be?

The one that leads to software that “work the way people expect when they
think of the term “Unix””. I wonder who wrote the expression I quoted.

Pages:12345

rocksolid light 0.9.8
clearnet tor