Ravi Teja Paruchuri
Ravi Teja Paruchuri

Reputation: 35

how to use shutdown call in linux using assembly programming 64-bit?

i made this program as executable but the system is not shutting down.this also needs admin privs.

section .text
global _start
_start:
      mov rax,48 ;shutdown system call
      mov rdi,60 ;time taken to shutdown(1 hour)
      syscall
      mov rax,60
      mov rdi,0
      syscall 

Upvotes: 0

Views: 886

Answers (1)

fuz
fuz

Reputation: 93082

The shutdown system call does not shut down the system. It implements the shutdown() function which shuts down communication on a socket. If you want to turn off the system, use the reboot() system call. See reboot(2) for documentation.

However, be advised that calling reboot with appropriate arguments immediately turns off the system without giving software time to shut down properly and without synchronising the file systems. I strongly recommend you to instead shut down the system by invoking the shutdown utility which does the right thing depending on your init system. If you don't want to do that, you should at least invoke sync() first to commit all in-flight data to disk.

Upvotes: 3

Related Questions