1 /* 2 * A process monitor abstraction. 3 * 4 * Copyright (C) 2022, 2023 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #pragma once 23 24 #include <fsserver/notification.h> 25 #include <resource/resource.h> 26 27 #include "parent_notification_object_interface.h" 28 29 30 31 /* A process monitor receiving signals from a task. */ 32 33 class ProcessMonitor : public ParentNotificationObject, public NotificationSupport, 34 public Resource 35 { 36 protected: 37 38 /* Resources associated with the created process. */ 39 40 l4_cap_idx_t _pager = L4_INVALID_CAP, _mapped_pager = L4_INVALID_CAP, 41 _parent = L4_INVALID_CAP, _mapped_parent = L4_INVALID_CAP, 42 _task = L4_INVALID_CAP, _mapped_task = L4_INVALID_CAP, 43 _thread = L4_INVALID_CAP, _mapped_thread = L4_INVALID_CAP; 44 45 /* Notification support. */ 46 47 l4_cap_idx_t _notifier = L4_INVALID_CAP; 48 49 public: 50 explicit ProcessMonitor(); 51 52 /* Server details. */ 53 54 virtual ipc_server_default_config_type config(); 55 56 virtual void *interface() 57 { return static_cast<ParentNotificationObject *>(this); } 58 59 /* Capability management. */ 60 61 virtual void set_pager(l4_cap_idx_t cap, l4_cap_idx_t mapped_cap); 62 virtual void set_parent(l4_cap_idx_t cap, l4_cap_idx_t mapped_cap); 63 virtual void set_task(l4_cap_idx_t cap, l4_cap_idx_t mapped_cap); 64 virtual void set_thread(l4_cap_idx_t cap, l4_cap_idx_t mapped_cap); 65 66 /* Lifecycle management. */ 67 68 virtual void pager_ended(); 69 70 /* Resource methods. */ 71 72 virtual void close(); 73 74 /* Parent methods. */ 75 76 virtual long signal(unsigned long sig, unsigned long val); 77 78 /* Notification methods. */ 79 80 virtual long subscribe(l4_cap_idx_t notifier, notify_flags_t flags); 81 82 virtual long unsubscribe(); 83 }; 84 85 /* vim: tabstop=2 expandtab shiftwidth=2 86 */