Last active
September 23, 2023 01:14
-
-
Save bg1bgst333/2dcc21b84643ab748ba1 to your computer and use it in GitHub Desktop.
system#system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ヘッダファイルのインクルード */ | |
#include <stdio.h> /* 標準入出力 */ | |
#include <stdlib.h> /* 標準ユーティリティ */ | |
#include <sys/types.h> /* 派生型 */ | |
#include <unistd.h> /* UNIX標準 */ | |
/* main関数の定義 */ | |
int main(void){ | |
/* 変数の宣言 */ | |
pid_t pid; /* getpidでプロセスIDを取得し, pidに格納. */ | |
/* プロセスIDの取得 */ | |
pid = getpid(); /* getpidでプロセスIDを取得し, pidに格納. */ | |
printf("pid = %d\n", pid); /* printfでpidを出力. */ | |
/* 1分間(60秒間)待つ. */ | |
sleep(60); /* sleepで60秒間休止. */ | |
/* systemを呼ぶ直前. */ | |
printf("system before.\n"); /* "system before."を出力する. */ | |
/* プロセスの実行. */ | |
system("./system_sub 123 abc xyz"); /* systemで"./system_sub"を引数"123", "abb", "xyz"として実行.(systemにより, system_mainのプロセスとは別にsystem_subのプロセスが生成される.) */ | |
/* 1分間(60秒間)待つ. */ | |
sleep(60); /* sleepで60秒間休止. */ | |
/* プログラムの終了 */ | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ヘッダファイルのインクルード */ | |
#include <stdio.h> /* 標準入出力 */ | |
#include <sys/types.h> /* 派生型 */ | |
#include <unistd.h> /* UNIX標準 */ | |
/* main関数の定義 */ | |
int main(int argc, char *argv[]){ | |
/* 変数の宣言 */ | |
pid_t pid; /* プロセスIDを格納するpid_t型変数pid. */ | |
int i; /* ループ用変数i */ | |
/* プロセスIDの取得 */ | |
pid = getpid(); /* getpidでプロセスIDを取得し, pidに格納. */ | |
printf("pid = %d\n", pid); /* printfでpidを出力. */ | |
/* コマンドライン引数の出力. */ | |
for (i = 0; i < argc; i++){ /* argcの数繰り返す. */ | |
/* argvの出力. */ | |
printf("argv[%d] = %s\n", i, argv[i]); /* argvの各要素を出力. */ | |
} | |
/* 1分間(60秒)待つ. */ | |
sleep(60); /* sleepで60秒間休止. */ | |
/* プログラムの終了. */ | |
return 0; | |
} |
Torvicemm
commented
Sep 23, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment