June 29th, 2005


userinfo senji
2005/06/29 10:37:00 - Error

< | 9 glosses | comment | > )

userinfo simont
[userpic]
2005/06/29 10:47:58
This idea is only half-baked as yet and I haven't done any of the backup research, but I wonder if there's anything we can set up by using a Unix domain socket as stderr and using recvmsg().

sendmsg() is more general than send(), not only because it allows the data sent to be gathered from various different parts of the sending process's memory, but also because it permits the attaching of ancillary strange information to the message being sent. (This, in particular, is how you pass file descriptors between unrelated processes across a Unix socket.)

So if, at the start of your shell session, you established a Unix domain socketpair, put the reading half in a process which looped on readmsg() and output the data to whatever the original stderr was, and in the other process you put the sending half in fd 2 and then exec()ed your real shell, then any process doing sendmsg() rather than write() on fd 2 would be able to pass strange ancillary information to the readmsg()ing process.

That by itself isn't terribly useful, but if we also did a small kernel hack which allowed you to (say) set a magic option on the socket which had the effect that ordinary write()s became equivalent to sendmsg() with the sending pid in the ancillary data, then the readmsg()ing process would be able to pull that out and annotate what got sent to your terminal.

It's still not very pretty, but it's more general than LD_PRELOAD...
reply | thread )
userinfo simont
[userpic]
2005/06/29 10:49:37
Ahem. For "readmsg" read "recvmsg" throughout.
reply | parent | thread )
userinfo senji
[userpic]
2005/06/29 11:25:24
Bleh, but yes I can see how that could work.

I see a problem though in that you have to deal with stderr in a non-blocking way, so it may be hard to tell where the beginning of a message is.
reply | parent | thread )
userinfo fanf
[userpic]
2005/06/29 18:07:38
Assume that newlines are message delimiters.
reply | parent | thread )

< | 9 glosses | comment | > )

Error - Squaring the circle... — LiveJournal

> log in
> recent entries
> fiends
> archive
> toothywiki page
> profile
> new entry
> recent comments


> go to top