[ot] named sockets

Adam (adam@cfar.umd.edu)
Mon, 7 May 2001 21:47:33 -0400 (EDT)


I kind of carelessly deleted /tmp/.X11-unix/X0. Now the thing is that
some programs which had not opened the socket before, can't connect to X.

The simplest solution would be just restart X, but that's too much effort
to me.

So I'm wondering, is there a way, kind of like "relink" system call which
coule take existing file descriptor (they are still so the fd is there,
just unlinked) and link it back to file name?

doing mksock X0 [*], does not do the trick as the fd is different.

[*]
/* mksock - make a Unix domain socket */
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
int main(int argc, char **argv) {
int sd; struct sockaddr_un sin;
if ((sd = socket(AF_UNIX, SOCK_STREAM, 0))
== -1) exit(1);
strcpy(sin.sun_path, argv[1]);
sin.sun_family = AF_UNIX;
if ((bind(sd, &sin, sizeof(sin)) == -1)) exit(1);
exit(0);
}

-- 
Adam
http://www.eax.com	The Supreme Headquarters of the 32 bit registers

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/