Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
ALPACA
CASPER
katcp
Commits
958de62d
Commit
958de62d
authored
13 years ago
by
Marc Welz
Browse files
Options
Download
Email Patches
Plain Diff
Moved around fork parent, log stuff
parent
425fc48f
master
rfsoc/mixer
rfsoc/rfdc
rfsoc/rfdc-dsa-vop
v0.2.0
v0.1.0
test
memcpy
alpha
No related merge requests found
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
katcp/Makefile
+2
-2
katcp/Makefile
katcp/fork-parent.c
+0
-0
katcp/fork-parent.c
katcp/fork-parent.h
+0
-0
katcp/fork-parent.h
kcs/Makefile
+1
-1
kcs/Makefile
kcs/kcserver.c
+1
-1
kcs/kcserver.c
log/Makefile
+2
-2
log/Makefile
log/log.c
+48
-7
log/log.c
with
54 additions
and
13 deletions
+54
-13
katcp/Makefile
+
2
-
2
View file @
958de62d
...
...
@@ -7,8 +7,8 @@ SHARED = libkatcp.so
CFLAGS
+=
-fPIC
SUB
=
examples utils
SRC
=
line.c netc.c dispatch.c loop.c log.c time.c shared.c misc.c server.c client.c ts.c nonsense.c notice.c job.c parse.c rpc.c queue.c map.c kurl.c version.c
HDR
=
katcp.h katcl.h katpriv.h
SRC
=
line.c netc.c dispatch.c loop.c log.c time.c shared.c misc.c server.c client.c ts.c nonsense.c notice.c job.c parse.c rpc.c queue.c map.c kurl.c version.c
fork-parent.c
HDR
=
katcp.h katcl.h katpriv.h
fork-parent.h
OBJ
=
$(
patsubst %.c,%.o,
$(
SRC
))
...
...
This diff is collapsed.
Click to expand it.
k
cs
/fork-parent.c
→
k
atcp
/fork-parent.c
+
0
-
0
View file @
958de62d
File moved
This diff is collapsed.
Click to expand it.
k
cs
/fork-parent.h
→
k
atcp
/fork-parent.h
+
0
-
0
View file @
958de62d
File moved
This diff is collapsed.
Click to expand it.
kcs/Makefile
+
1
-
1
View file @
958de62d
...
...
@@ -5,7 +5,7 @@ LIB = -L$(KATCP) -lkatcp
SERVER
=
kcs
SRCSHARED
=
shared.c
SRC
=
$(
SRCSHARED
)
udpear.c subprocess.c statemachine.c roachpool.c
fork-parent.c
execpy.c parser.c kcserver.c basic.c
SRC
=
$(
SRCSHARED
)
udpear.c subprocess.c statemachine.c roachpool.c execpy.c parser.c kcserver.c basic.c
OBJ
=
$(
patsubst %.c,%.o,
$(
SRC
))
all
:
$(SERVER)
...
...
This diff is collapsed.
Click to expand it.
kcs/kcserver.c
+
1
-
1
View file @
958de62d
...
...
@@ -22,9 +22,9 @@
#include
<sys/utsname.h>
#include
<katcp.h>
#include
<fork-parent.h>
#include
"kcs.h"
#include
"fork-parent.h"
void
usage
(
char
*
app
)
{
...
...
This diff is collapsed.
Click to expand it.
log/Makefile
+
2
-
2
View file @
958de62d
...
...
@@ -3,8 +3,8 @@ include ../Makefile.inc
INC
=
-I
$(
KATCP
)
LIB
=
-L
$(
KATCP
)
-lkatcp
EXE
=
k
l
SRC
=
k
l.c
EXE
=
k
cplog
SRC
=
l
og
.c
OBJ
=
$(
patsubst %.c,%.o,
$(
SRC
))
...
...
This diff is collapsed.
Click to expand it.
log/
k
l.c
→
log/l
og
.c
+
48
-
7
View file @
958de62d
...
...
@@ -14,16 +14,17 @@
#include
<katcl.h>
#include
<katcp.h>
#include
<katpriv.h>
#include
<fork-parent.h>
#define NAME "kl"
static
volatile
int
log_level
=
KATCP_LEVEL_INFO
;
static
volatile
int
log_changed
=
0
;
static
volatile
int
log_reload
=
0
;
void
usage
(
char
*
app
)
{
printf
(
"usage: %s [-l level] [-o logfile] [-a reconnect-attempts] [-d] [-s server:port]
\n
"
,
app
);
printf
(
"usage: %s [-l level] [-o logfile] [-a reconnect-attempts] [-d]
[-t]
[-s server:port]
\n
"
,
app
);
}
static
void
handle_signal
(
int
signal
)
...
...
@@ -32,30 +33,31 @@ static void handle_signal(int signal)
case
SIGUSR1
:
if
(
log_level
>
KATCP_LEVEL_TRACE
){
log_level
--
;
log_changed
=
1
;
}
break
;
case
SIGUSR2
:
if
(
log_level
<
KATCP_LEVEL_OFF
){
log_level
++
;
log_changed
=
1
;
}
break
;
case
SIGHUP
:
log_
level
=
KATCP_LEVEL_INFO
;
log_
reload
=
1
;
break
;
default
:
return
;
}
log_changed
=
1
;
}
int
main
(
int
argc
,
char
**
argv
)
{
char
*
level
,
*
app
,
*
server
,
*
output
;
int
run
,
fd
,
i
,
j
,
c
,
verbose
,
attempts
,
detach
,
result
;
int
run
,
fd
,
i
,
j
,
c
,
verbose
,
attempts
,
detach
,
result
,
truncate
,
flags
;
struct
katcl_parse
*
p
;
struct
katcl_line
*
ls
,
*
lo
;
struct
sigaction
sa
;
...
...
@@ -66,11 +68,14 @@ int main(int argc, char **argv)
verbose
=
0
;
attempts
=
2
;
detach
=
0
;
truncate
=
0
;
server
=
NULL
;
output
=
NULL
;
level
=
NULL
;
flags
=
0
;
/* placate -Wall */
while
(
i
<
argc
)
{
if
(
argv
[
i
][
0
]
==
'-'
)
{
c
=
argv
[
i
][
j
];
...
...
@@ -86,7 +91,17 @@ int main(int argc, char **argv)
break
;
case
'd'
:
detach
=
1
-
detach
;
detach
=
1
;
j
++
;
break
;
case
'f'
:
detach
=
0
;
j
++
;
break
;
case
't'
:
truncate
=
1
;
j
++
;
break
;
...
...
@@ -150,6 +165,13 @@ int main(int argc, char **argv)
}
}
if
(
detach
){
if
(
fork_parent
()
<
0
){
fprintf
(
stderr
,
"%s: unable to detach process
\n
"
,
app
);
return
EX_OSERR
;
}
}
sa
.
sa_handler
=
handle_signal
;
#if 0
sa.sa_flags = SA_RESTART;
...
...
@@ -181,7 +203,11 @@ int main(int argc, char **argv)
}
fd
=
STDOUT_FILENO
;
}
else
{
fd
=
open
(
output
,
O_CREAT
|
O_WRONLY
|
O_APPEND
,
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IWGRP
|
S_IROTH
);
flags
=
O_CREAT
|
O_WRONLY
;
if
(
truncate
==
0
){
flags
|=
O_APPEND
;
}
fd
=
open
(
output
,
flags
,
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IWGRP
|
S_IROTH
);
if
(
fd
<
0
){
fprintf
(
stderr
,
"%s: unable to open file %s: %s
\n
"
,
app
,
output
,
strerror
(
errno
));
return
EX_OSERR
;
...
...
@@ -212,7 +238,22 @@ int main(int argc, char **argv)
return
EX_OSERR
;
}
if
(
detach
){
fclose
(
stderr
);
}
for
(
run
=
1
;
run
>
0
;){
if
(
log_reload
>
0
){
if
(
output
){
fd
=
open
(
output
,
flags
,
S_IRUSR
|
S_IWUSR
|
S_IRGRP
|
S_IWGRP
|
S_IROTH
);
if
(
fd
>=
0
){
exchange_katcl
(
lo
,
fd
);
}
}
log_reload
=
0
;
}
/* WARNING: will only run after the next message - may have to interrupt syscall to get past this */
if
(
log_changed
>
0
){
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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
Menu
Explore
Projects
Groups
Topics
Snippets