- if ((fd = open(device, O_WRONLY, 0)) < 0) {
- fprintf(stderr, "wall: %s: ", device);
- perror((char *)NULL);
- }
- flags = fcntl(fd, F_GETFL, 0);
- if (!(flags & FNDELAY)) {
- /* NDELAY bit not set; if can't set, fork instead */
- if (fcntl(fd, F_SETFL, flags|FNDELAY) == -1) {
- flags = 0;
- goto forkit;
- }
+ /*
+ * open will fail on slip lines or exclusive-use lines
+ * if not running as root
+ */
+ if ((fd = open(device, O_WRONLY|(nonblock ? O_NONBLOCK : 0), 0)) < 0) {
+ if (errno != EBUSY && errno != EPERM)
+ (void)fprintf(stderr, "wall: %s: %s\n",
+ device, strerror(errno));
+ return;