4

This question is follow-up for this question.

When the bash command is issued by posix_spawn() I get the message:

bash: no job control in this shell

I think is because in the fork sequence there is call to the function setsid() and I don't know how to simulate this operation while using posix_spawn().

Is there a way to make new session for the bash process?

Community
  • 1
  • 1
AZur
  • 39
  • 6

1 Answers1

2

You can't. It's not part of the current posix_spawn interface. Adding it has been discussed at http://austingroupbugs.net/view.php?id=1044 and apparently at least one implementation (QNX) provides POSIX_SPAWN_SETSID as an extension, but to stay standard compliant you need to use fork.

Using fork shouldn't be an issue if the parent process is small, so I imagine that to get the best of both worlds, you could use posix_spawn to launch a small helper binary that forks and calls setsid. IMO, using setsid should be rare enough for the small additional cost of double-execing to be negligible.

Petr Skocik
  • 58,047
  • 6
  • 95
  • 142