when setsid failed, the pid and sid doesn't equal, so remove following
condition statement.
if (getsid(0) != pid)
Following is the content and output of test program.
root@p1022ds:~# cat sid_test.c
int main() {
pid_t pid;
pid = setsid();
if (pid < 0) {
int fd;
pid = getpid();
if (getsid(0) != pid) {
printf("setsid failed: pid %d ppid %d sid %d pgid %d",
pid, getppid(),
getsid(0), getpgid(0));
}
}
}
root@p1022ds:~# ./sid_test
setsid failed: pid 2452 ppid 2408 sid 2408 pgid 2452
root@p1022ds:~#
Fix following runtime issue of getty:
root@p1025:~# getty 115200 /dev/ttyQE1
getty: setsid: Operation not permitted
Signed-off-by: Zhenhua Luo <[email protected]>
---
loginutils/getty.c | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 0f060ae..6bfdf43 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -548,15 +548,6 @@ int getty_main(int argc UNUSED_PARAM, char **argv)
* a session leader - which is quite possible for getty!
*/
pid = getpid();
- if (getsid(0) != pid) {
- //for debugging:
- //bb_perror_msg_and_die("setsid failed:"
- // " pid %d ppid %d"
- // " sid %d pgid %d",
- // pid, getppid(),
- // getsid(0), getpgid(0));
- bb_perror_msg_and_die("setsid");
- }
/* Looks like we are already a session leader.
* In this case (setsid failed) we may still have ctty,
* and it may be different from tty we need to control!
--
1.9.1
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox