Commit Graph

14 Commits

Author SHA1 Message Date
Tom
d6174f9c79 SystemServer: Wait on all waitable children in SIGCHLD handler
We need to call waitpid until no more waitable children are available.
This is necessary because SIGCHLD signals may coalesce into one when
multiple children terminate almost simultaneously.

This fixes random zombie processes sticking around after e.g. closing
Browser.

Also, switch to EventLoop's asynchronous signal handling mechanism,
which allows more complex operations in the signal handler.
2020-12-02 12:57:15 +01:00
Itamar
fec4152220 LibCore: Add ensure_parent_directories to LibCore::File
Moved the implementation in SystemServer/Service.cpp to LibCore.
2020-09-30 21:46:59 +02:00
Andreas Kling
e2f32b8f9d LibCore: Make Core::Object properties more dynamic
Instead of everyone overriding save_to() and set_property() and doing
a pretty asymmetric job of implementing the various properties, let's
add a bit of structure here.

Object properties are now represented by a Core::Property. Properties
are registered with a getter and setter (optional) in constructors.
I've added some convenience macros for creating and registering
properties, but this does still feel a bit bulky. We'll have to
iterate on this and see where it goes.
2020-09-15 21:46:26 +02:00
Ben Wiederhake
e682967d7e LibCore: Prefer strlcpy over strncpy, fix overflow
A malicious caller can create a SocketAddress for a local unix socket with an
over-long name that does not fit into struct sock_addr_un.
- Socket::connet: This caused the 'sun_path' field to
  overflow, probably overwriting the return pointer of the call frame, and thus
  crashing the process (in the best case).
- SocketAddress::to_sockaddr_un: This triggered a RELEASE_ASSERT, and thus
  crashing the process.

Both have been fixed to return a nice error code instead of crashing.
2020-08-24 00:45:03 +02:00
Muhammad Zahalqa
16e86a3dda
SystemServer: Minor #include cleanup in Service.cpp (#3227) 2020-08-20 20:57:39 +02:00
Andreas Kling
46e53417c9 SystemServer: Adjust assertion+comment for new dup2() behavior
dup2(fd, fd) will no longer clear CLOEXEC on the descriptor.
2020-08-15 11:14:09 +02:00
Ruairidh MacLeod
6400122760
SystemServer: Fix typo (exist -> exit) (#2615)
Small typo that I noticed on the latest OS hacking video!
2020-06-23 14:52:15 +02:00
Andreas Kling
79d3c5723f SystemServer: Put some debug spam behind #ifdefs 2020-06-22 21:18:55 +02:00
Sergey Bugaev
701994bfd1 SystemServer: Add support for accepting socket connections :^)
You can now ask SystemServer to not only listen for connections on the socket,
but to actually accept them, and to spawn an instance of the service for each
client connection. In this case, it's the accepted, not listening, socket that
the service processes will receive using socket takeover.

This mode obviously requires the service to be a multi-instance service.
2020-06-09 21:12:34 +02:00
Sergey Bugaev
ac4c2f890f SystemServer: Add support for multi-instance services
For this kind of services, there's no single PID of a running instance;
there may be multiple, or no instances of the service running at any time.
No keepalive functionality is available in this mode, since "alive" doesn't
make sense for multi-instance services.

At the moment, there's no way to actually create multiple instances of
a service; this is going to be added in the next commit.
2020-06-09 21:12:34 +02:00
Sergey Bugaev
856e4853f4 SystemServer: Add BootModes and Environment service options
SystemServer will now look at the boot mode, as specified on the kernel command
line, and only launch the services configured for that boot mode.
2020-05-27 11:19:38 +02:00
Sergey Bugaev
4139838a93 Userland et al: Pledge sigaction when needed
* In some cases, we can first call sigaction()/signal(), then *not* pledge
  sigaction.
* In other cases, we pledge sigaction at first, call sigaction()/signal()
  second, then pledge again, this time without sigaction.
* In yet other cases, we keep the sigaction pledge. I suppose these could all be
  migrated to drop it or not pledge it at all, if somebody is interested in
  doing that.
2020-05-26 14:35:10 +02:00
Sergey Bugaev
450a2a0f9c Build: Switch to CMake :^)
Closes https://github.com/SerenityOS/serenity/issues/2080
2020-05-14 20:15:18 +02:00
Andreas Kling
cf3b58fbe8 Services: Renamed from Servers
It didn't feel right to have a "DHCPClient" in a "Servers" directory.
Rename this to Services to better reflect the type of programs we'll
be putting in there.
2020-05-08 21:57:44 +02:00