{
if (udata.u_proc->p_pgrp == t->pgrp)
return;
+ /* We probably want to special case a helper here because we need
+ to handle the funnier side effects ? */
ssig(udata.u_proc, SIGTTIN);
/* So we halt */
pause(0);
/* So we halt */
pause(0);
}
+
+int tcsetpgrp(struct tty *t, char *data) /* data is user pointer */
+{
+ uint16_t grp = ugetw(data);
+ uint16_t ses = udata.u_ptab->p_session;
+ ptptr p;
+ uint8_t found = 0;
+
+ /* Controlling tty check is done by caller */
+
+ /* No change -> ok */
+ if (grp == tty->pgrp)
+ return 0;
+
+ for (p = ptab; p < ptab_end; ++p) {
+ /* The group exists */
+ if (p->p_pgrp == grp) {
+ /* but not within our session */
+ if (p->p_session != ses) {
+ udata.u_error = EPERM;
+ return -1;
+ }
+ /* So it's a valid group and in our session */
+ tty->pgrp = grp;
+ return 0;
+ }
+ }
+ udata.u_error = EINVAL;
+ return -1;
+}
#undef res
#undef rlim
+/*******************************************
+ setpgid (pid, pgid) Function ??
+ uint16_t npid;
+ uint16_t npgid;
+ *******************************************/
+
+#define npid (uint16_t)udata.u_argn
+#define npgid (uint16_t)udata.u_argn1
+
+arg_t _setpgid(void)
+{
+ ptptr p, t;
+ uint16_t ses = udata.u_ptab->p_session;
+
+ /* pid 0 means "self" */
+ if (npid == 0)
+ t = udata.u_ptab;
+ else {
+ for (p = ptab; p < ptab_end; ++p) {
+ if (p->p_pid == npid)
+ t = p;
+ }
+ }
+ if (t == NULL) {
+ udata.u_error = ESRCH;
+ return -1;
+ }
+
+ if (t->p_session != udata.u_ptab->p_session)
+ goto invalid;
+
+ if (npgid == 0)
+ npgid = t->p_pid;
+
+ /* Check if the group is in use with a different session */
+ for (p = ptab; p < ptab_end; ++p)
+ if (p->p_pgrp == npgid && p->p_session != ses)
+ goto invalid;
+
+ t->p_pgrp = npgid;
+ return 0;
+
+invalid:
+ udata.u_error = EPERM;
+ return -1;
+}
+
+#undef npid
+#undef npgid
+
+/*******************************************
+ setsid (void) Function ??
+ *******************************************/
+
+arg_t _setsid(void)
+{
+ ptptr p;
+ uint16_t pid = udata.u_ptab->p_pid;
+
+ for (p = ptab; p < ptab_end; ++p) {
+ if (p->p_pgid == pid || p->p_session == pid) {
+ udata.u_error = EPERM;
+ return -1;
+ }
+ }
+ p = udata.u_ptab;
+ p->p_pgrp = pid;
+ p->p_session = pid;
+ udata.u_ctty = NULL;
+ return 0;
+}
+
+/*******************************************
+ getsid (pid) Function ??
+ uint16_t pid;
+ *******************************************/
+
+arg_t _getsid(void)
+{
+ ptptr p;
+ for (p = ptab; p < ptab_end; ++p) {
+ if (p->p_pid == pid)
+ return p->p_session;
+ }
+ udata.u_error = ESRCH;
+ return -1;
+}
+
return -1;
sgrpsig(t->pgrp, SIGWINCH);
return 0;
+ case TIOCGPGRP:
+ return uputw(t->pgrp, data);
+#ifdef CONFIG_LEVEL_2
+ case TIOCSPGRP:
+ /* Only applicable via controlling terminal */
+ if (minor != udata.u_ptab->p_tty) {
+ udata.u_error = ENOTTY;
+ return -1;
+ }
+ return tcsetpgrp(minor, t, data);
+#endif
default:
udata.u_error = ENOTTY;
return -1;