Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
S
scom
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
SulinOS
scom
Commits
a294df87
Kaydet (Commit)
a294df87
authored
Eyl 14, 2019
tarafından
ali
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Daemon modu ekledim
😎
üst
0788f96a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
0 deletions
+64
-0
daemon.c
scom/src/daemon.c
+60
-0
main.c
scom/src/main.c
+4
-0
No files found.
scom/src/daemon.c
0 → 100644
Dosyayı görüntüle @
a294df87
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <syslog.h>
static
void
skeleton_daemon
()
{
pid_t
pid
;
/* Fork off the parent process */
pid
=
fork
();
/* An error occurred */
if
(
pid
<
0
)
exit
(
EXIT_FAILURE
);
/* Success: Let the parent terminate */
if
(
pid
>
0
)
exit
(
EXIT_SUCCESS
);
/* On success: The child process becomes session leader */
if
(
setsid
()
<
0
)
exit
(
EXIT_FAILURE
);
/* Catch, ignore and handle signals */
//TODO: Implement a working signal handler */
signal
(
SIGCHLD
,
SIG_IGN
);
signal
(
SIGHUP
,
SIG_IGN
);
/* Fork off for the second time*/
pid
=
fork
();
/* An error occurred */
if
(
pid
<
0
)
exit
(
EXIT_FAILURE
);
/* Success: Let the parent terminate */
if
(
pid
>
0
)
exit
(
EXIT_SUCCESS
);
/* Set new file permissions */
umask
(
0
);
/* Change the working directory to the root directory */
/* or another appropriated directory */
chdir
(
"/"
);
/* Close all open file descriptors */
int
x
;
for
(
x
=
sysconf
(
_SC_OPEN_MAX
);
x
>=
0
;
x
--
)
{
close
(
x
);
}
/* Open the log file */
openlog
(
"firstdaemon"
,
LOG_PID
,
LOG_DAEMON
);
}
scom/src/main.c
Dosyayı görüntüle @
a294df87
...
...
@@ -30,6 +30,7 @@
#include "process.h"
#include "script.h"
#include "utils.h"
#include "daemon.c"
#include <stdio.h>
#include <stdlib.h>
...
...
@@ -80,6 +81,9 @@ main(int argc, char *argv[])
// Initialize parent process
proc_init
();
// Daemon start
skeleton_daemon
();
// Enter main loop
loop_exec
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment