Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/lib/libc/stdlib



On Wed, 28 Sep 2022, at 15:07:41 -0000 (UTC), Christos Zoulas wrote:
In article <20220928003547.D2375FA92%cvs.NetBSD.org@localhost>,
David H. Gutteridge <source-changes-d%NetBSD.org@localhost> wrote:
-=-=-=-=-=-

Module Name:	src
Committed By:	gutteridge
Date:		Wed Sep 28 00:35:47 UTC 2022

Modified Files:
	src/lib/libc/stdlib: posix_openpt.3

Log Message:
posix_openpt.3: reflect flag changes from r. 1.44 of tty_ptm.c

Some flags are now accepted, others are still ignored. (E.g., other
BSDs would return EINVAL if O_RDWR wasn't passed, and we now accept
O_NONBLOCK but not O_CLOEXEC.)

How so?

#define FCNTLFLAGS (FAPPEND|FASYNC|FFSYNC|FNONBLOCK|FDSYNC|FRSYNC|FALTIO|\
                                              ^^^^^^^^^
                        FDIRECT|FNOSIGPIPE)
/* bits to save after open(2) */
#define FMASK           (FREAD|FWRITE|FCNTLFLAGS|FEXEC)
                                     ^^^^^^^^^^

Best,

christos

Hi Christos,

I'm sorry, I don't follow your question? I wrote "we now accept
O_NONBLOCK...", which is what I'm reading you're saying too?

(O_CLOEXEC, on the other hand, is ignored, at the moment.)

$ cat open_test.c
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>

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

	printf("Regular file (read-only) with O_NONBLOCK | O_CLOEXEC.\n");
	if ((fd = open("/etc/release", O_RDONLY | O_NONBLOCK | O_CLOEXEC)) < 0)
		printf("Failed to get file handle.\n");
	else {
		printf("Descriptor flags: %d\n", flags = fcntl(fd, F_GETFD));
		printf("Status flags: %d\n", flags = fcntl(fd, F_GETFL, 0));
		close(fd);
	}

	printf("POSIX pt cloning device with O_NONBLOCK | O_CLOEXEC.\n");
if ((fd = open("/dev/ptmx", O_RDWR | O_NOCTTY | O_NONBLOCK | O_CLOEXEC)) < 0)
		printf("Failed to open /dev/ptmx.\n");
	else {
		printf("Descriptor flags: %d\n", flags = fcntl(fd, F_GETFD));
		printf("Status flags: %d\n", flags = fcntl(fd, F_GETFL, 0));
		close(fd);
	}

	return 0;
}

$ ./open_test
Regular file (read-only) with O_NONBLOCK | O_CLOEXEC.
Descriptor flags: 1
Status flags: 4
POSIX pt cloning device with O_NONBLOCK | O_CLOEXEC.
Descriptor flags: 0
Status flags: 6

Regards,

Dave


Home | Main Index | Thread Index | Old Index