반응형

 

syscall의 상수값들

 

https://fossies.org/windows/misc/go1.18.9.windows-amd64.zip/go/src/runtime/sys_linux_s390x.s

   12 #define SYS_exit                  1
   13 #define SYS_read                  3
   14 #define SYS_write                 4
   15 #define SYS_open                  5
   16 #define SYS_close                 6
   17 #define SYS_getpid               20
   18 #define SYS_kill                 37
   19 #define SYS_pipe         42
   20 #define SYS_brk          45
   21 #define SYS_fcntl                55
   22 #define SYS_mmap                 90
   23 #define SYS_munmap               91
   24 #define SYS_setitimer           104
   25 #define SYS_clone               120
   26 #define SYS_sched_yield         158
   27 #define SYS_nanosleep           162
   28 #define SYS_rt_sigreturn        173
   29 #define SYS_rt_sigaction        174
   30 #define SYS_rt_sigprocmask      175
   31 #define SYS_sigaltstack         186
   32 #define SYS_madvise             219
   33 #define SYS_mincore             218
   34 #define SYS_gettid              236
   35 #define SYS_futex               238
   36 #define SYS_sched_getaffinity   240
   37 #define SYS_tgkill              241
   38 #define SYS_exit_group          248
   39 #define SYS_epoll_create        249
   40 #define SYS_epoll_ctl           250
   41 #define SYS_epoll_wait          251
   42 #define SYS_timer_create        254
   43 #define SYS_timer_settime       255
   44 #define SYS_timer_delete        258
   45 #define SYS_clock_gettime       260
   46 #define SYS_pipe2       325
   47 #define SYS_epoll_create1       327

 

소스코드

#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <signal.h>

int main(int argc, char *argv[]) {
        pid_t pid;

        pid = syscall(SYS_getpid);
        printf("syscall로 부른 pid: %d\n", pid);
        printf("getpid로 부른 pid: %d\n", getpid());

        // 인자를 넣어서 해당 pid에 SIGHUP를 보내보자
        syscall(SYS_tgkill, getpid(), pid, SIGHUP);
}

 

 

출력화면

syscall로 부른 pid: 6659
getpid로 부른 pid: 6659
zsh: hangup     ./a.out
반응형

'Linux > Linux' 카테고리의 다른 글

[Linux] 라즈베리파이에 한글폰트 설치  (0) 2023.01.15
Netlink 정리  (0) 2023.01.06
[Linux] Select 함수 (작성중)  (0) 2022.12.01
[Linux] 표준 에러 코드  (0) 2022.11.20
[Linux] xfrm command  (0) 2022.06.28