mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-18 17:14:28 +00:00
Acked-by: Mike Rapoport <rppt@linux.ibm.com> Signed-off-by: Adrian Reber <areber@redhat.com>
50 lines
No EOL
1.1 KiB
C
50 lines
No EOL
1.1 KiB
C
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <sys/socket.h>
|
|
#include <netinet/in.h>
|
|
|
|
#include "zdtmtst.h"
|
|
|
|
const char *test_doc = "Check SO_LINGER socket option";
|
|
const char *test_author = "Radostin Stoyanov <rstoyanov1@gmail.com>";
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
int sk;
|
|
struct linger dump = { true, 30 }, restore = { 0, 0 };
|
|
socklen_t optlen = sizeof(restore);
|
|
|
|
test_init(argc, argv);
|
|
|
|
sk = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
|
if (sk < 0) {
|
|
pr_perror("Can't create socket");
|
|
return 1;
|
|
}
|
|
|
|
if (setsockopt(sk, SOL_SOCKET, SO_LINGER, &dump, sizeof(dump)) < 0) {
|
|
pr_perror("setsockopt SO_LINGER");
|
|
return 1;
|
|
}
|
|
|
|
test_daemon();
|
|
test_waitsig();
|
|
|
|
if (getsockopt(sk, SOL_SOCKET, SO_LINGER, &restore, &optlen) < 0) {
|
|
pr_perror("getsockopt SO_LINGER");
|
|
return 1;
|
|
}
|
|
|
|
if (restore.l_onoff != dump.l_onoff) {
|
|
fail("linger.l_onoff has incorrect value (%d != %d)", restore.l_onoff, dump.l_onoff);
|
|
return 1;
|
|
}
|
|
|
|
if (restore.l_linger != dump.l_linger) {
|
|
fail("linger.l_linger has incorrect value (%d != %d)", restore.l_linger, dump.l_linger);
|
|
return 1;
|
|
}
|
|
|
|
pass();
|
|
return 0;
|
|
} |